Skip to content

Commit

Permalink
Merge b75b95a into 3e6102e
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey committed Jun 2, 2020
2 parents 3e6102e + b75b95a commit 001f539
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/js/media-selector/helpers/get-config.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Internal dependencies
*/
import getConfig from '../../../../assets/src/media-selector/helpers/get-config';

describe( 'get-config', () => {
beforeEach( () => {
// Delete the existing
delete window.unsplash;
window.unsplash = {
test: '123',
};
} );

afterAll( () => {
// Delete the existing
delete window.unsplash;
} );

it( 'check key', () => {
expect( getConfig( 'test' ) ).toBe( '123' );
} );

it( 'invalid key', () => {
expect( getConfig( 'wordpress' ) ).toBeUndefined();
} );

it( 'not set on window', () => {
delete window.unsplash;
expect( getConfig( 'wordpress' ) ).toBeUndefined();
} );
} );
14 changes: 14 additions & 0 deletions tests/js/media-selector/helpers/is-applicable-libraries.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Internal dependencies
*/
import checkLibrary from '../../../../assets/src/media-selector/helpers/is-applicable-libraries';

describe( 'is-applicable-libraries', () => {
it( 'check string of video', () => {
expect( checkLibrary( 'video' ) ).toBe( false );
} );

it( 'check string of library', () => {
expect( checkLibrary( 'library' ) ).toBe( true );
} );
} );
22 changes: 22 additions & 0 deletions tests/js/media-selector/helpers/is-image-included.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Internal dependencies
*/
import checkType from '../../../../assets/src/media-selector/helpers/is-image-included';

describe( 'is-image-included', () => {
it( 'check empty array', () => {
expect( checkType( [] ) ).toBe( false );
} );

it( 'check with video array', () => {
expect( checkType( [ 'video' ] ) ).toBe( false );
} );

it( 'check array with image', () => {
expect( checkType( [ 'image' ] ) ).toBe( true );
} );

it( 'check string of image', () => {
expect( checkType( 'image' ) ).toBe( true );
} );
} );
33 changes: 33 additions & 0 deletions tests/js/media-selector/helpers/is-unsplash-image.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Internal dependencies
*/
import checkImage from '../../../../assets/src/media-selector/helpers/is-unsplash-image';

describe( 'is-unsplash-image', () => {
it( 'valid attachment', () => {
const attachment = {
attributes: {
unsplash_order: 2,
id: 'fsfds',
},
};
expect( checkImage( attachment ) ).toBe( true );
} );
it( 'invalid attachment', () => {
const attachment = {
attributes: {
unsplash_order: 2,
id: 22,
},
};
expect( checkImage( attachment ) ).toBe( false );
} );
it( 'no order attachment', () => {
const attachment = {
attributes: {
id: 22,
},
};
expect( checkImage( attachment ) ).toBe( false );
} );
} );

0 comments on commit 001f539

Please sign in to comment.