Skip to content

Commit

Permalink
Small naming convetion tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Aug 1, 2018
1 parent 03c1492 commit 9f914ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/editor/src/components/page-attributes/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const applyWithDispatch = withDispatch( ( dispatch ) => {
const applyWithAPIDataItems = withAPIData( ( { postType, postId } ) => {
const isHierarchical = get( postType, [ 'hierarchical' ], false );
const restBase = get( postType, [ 'rest_base' ], false );
const queryString = {
const query = {
context: 'edit',
per_page: -1,
exclude: postId,
Expand All @@ -75,7 +75,7 @@ const applyWithAPIDataItems = withAPIData( ( { postType, postId } ) => {
order: 'asc',
};
return isHierarchical && restBase ?
{ items: addQueryArgs( `/wp/v2/${ restBase }`, queryString ) } :
{ items: addQueryArgs( `/wp/v2/${ restBase }`, query ) } :
{};
} );

Expand Down
26 changes: 13 additions & 13 deletions packages/url/src/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] };

Expand All @@ -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 = 'foo@wordpress.org';

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:foo@wordpress.org';

expect( prependHTTP( url ) ).toBe( url );
Expand Down

0 comments on commit 9f914ab

Please sign in to comment.