-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
13 changed files
with
123 additions
and
22 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
...elector/helpers/unset-unsplash-library.js → ...tor/controllers/unset-unsplash-library.js
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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export { default as getConfig } from './get-config'; | ||
export { default as importImages } from './import-images'; | ||
export { default as isApplicableLibraries } from './is-applicable-libraries'; | ||
export { default as isImageIncluded } from './is-image-included'; | ||
export { default as isUnsplashImage } from './is-unsplash-image'; | ||
export { default as preloadImage } from './preload-image'; |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getConfig } from '../../../../assets/src/media-selector/helpers'; | ||
|
||
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
14
tests/js/media-selector/helpers/is-applicable-libraries.spec.js
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isApplicableLibraries } from '../../../../assets/src/media-selector/helpers'; | ||
|
||
describe( 'is-applicable-libraries', () => { | ||
it( 'check string of video', () => { | ||
expect( isApplicableLibraries( 'video' ) ).toBe( false ); | ||
} ); | ||
|
||
it( 'check string of library', () => { | ||
expect( isApplicableLibraries( 'library' ) ).toBe( true ); | ||
} ); | ||
} ); |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isImageIncluded } from '../../../../assets/src/media-selector/helpers'; | ||
|
||
describe( 'is-image-included', () => { | ||
it( 'check empty array', () => { | ||
expect( isImageIncluded( [] ) ).toBe( false ); | ||
} ); | ||
|
||
it( 'check with video array', () => { | ||
expect( isImageIncluded( [ 'video' ] ) ).toBe( false ); | ||
} ); | ||
|
||
it( 'check array with image', () => { | ||
expect( isImageIncluded( [ 'image' ] ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'check string of image', () => { | ||
expect( isImageIncluded( 'image' ) ).toBe( true ); | ||
} ); | ||
} ); |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isUnsplashImage } from '../../../../assets/src/media-selector/helpers'; | ||
|
||
describe( 'is-unsplash-image', () => { | ||
it( 'valid attachment', () => { | ||
const attachment = { | ||
attributes: { | ||
unsplash_order: 2, | ||
id: 'fsfds', | ||
}, | ||
}; | ||
expect( isUnsplashImage( attachment ) ).toBe( true ); | ||
} ); | ||
it( 'invalid attachment', () => { | ||
const attachment = { | ||
attributes: { | ||
unsplash_order: 2, | ||
id: 22, | ||
}, | ||
}; | ||
expect( isUnsplashImage( attachment ) ).toBe( false ); | ||
} ); | ||
it( 'no order attachment', () => { | ||
const attachment = { | ||
attributes: { | ||
id: 22, | ||
}, | ||
}; | ||
expect( isUnsplashImage( attachment ) ).toBe( false ); | ||
} ); | ||
} ); |