-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03c1492
commit 9f914ab
Showing
2 changed files
with
15 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,28 +4,28 @@ | |
import { addQueryArgs, prependHTTP } from '../'; | ||
|
||
describe( 'addQueryArgs', () => { | ||
test( 'should append args to an URL without query string', () => { | ||
it( 'should append args to an URL without query string', () => { | ||
const url = 'https://andalouses.example/beach'; | ||
const args = { sun: 'true', sand: 'false' }; | ||
|
||
expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.example/beach?sun=true&sand=false' ); | ||
} ); | ||
|
||
test( 'should append args to an URL with query string', () => { | ||
it( 'should append args to an URL with query string', () => { | ||
const url = 'https://andalouses.example/beach?night=false'; | ||
const args = { sun: 'true', sand: 'false' }; | ||
|
||
expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.example/beach?night=false&sun=true&sand=false' ); | ||
} ); | ||
|
||
test( 'should update args to an URL with conflicting query string', () => { | ||
it( 'should update args to an URL with conflicting query string', () => { | ||
const url = 'https://andalouses.example/beach?night=false&sun=false&sand=true'; | ||
const args = { sun: 'true', sand: 'false' }; | ||
|
||
expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.example/beach?night=false&sun=true&sand=false' ); | ||
} ); | ||
|
||
test( 'should update args to an URL with array parameters', () => { | ||
it( 'should update args to an URL with array parameters', () => { | ||
const url = 'https://andalouses.example/beach?time[]=10&time[]=11'; | ||
const args = { beach: [ 'sand', 'rock' ] }; | ||
|
||
|
@@ -34,55 +34,55 @@ describe( 'addQueryArgs', () => { | |
} ); | ||
|
||
describe( 'prependHTTP', () => { | ||
test( 'should prepend http to a domain', () => { | ||
it( 'should prepend http to a domain', () => { | ||
const url = 'wordpress.org'; | ||
|
||
expect( prependHTTP( url ) ).toBe( 'http://' + url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to an email', () => { | ||
it( 'shouldn’t prepend http to an email', () => { | ||
const url = '[email protected]'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to an absolute URL', () => { | ||
it( 'shouldn’t prepend http to an absolute URL', () => { | ||
const url = '/wordpress'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to a relative URL', () => { | ||
it( 'shouldn’t prepend http to a relative URL', () => { | ||
const url = './wordpress'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to an anchor URL', () => { | ||
it( 'shouldn’t prepend http to an anchor URL', () => { | ||
const url = '#wordpress'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to a URL that already has http', () => { | ||
it( 'shouldn’t prepend http to a URL that already has http', () => { | ||
const url = 'http://wordpress.org'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to a URL that already has https', () => { | ||
it( 'shouldn’t prepend http to a URL that already has https', () => { | ||
const url = 'https://wordpress.org'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to a URL that already has ftp', () => { | ||
it( 'shouldn’t prepend http to a URL that already has ftp', () => { | ||
const url = 'ftp://wordpress.org'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
} ); | ||
|
||
test( 'shouldn’t prepend http to a URL that already has mailto', () => { | ||
it( 'shouldn’t prepend http to a URL that already has mailto', () => { | ||
const url = 'mailto:[email protected]'; | ||
|
||
expect( prependHTTP( url ) ).toBe( url ); | ||
|