-
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.
Block Directory: Use local assets with automatic asset detection (#24117
- Loading branch information
Showing
5 changed files
with
89 additions
and
102 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
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 |
---|---|---|
@@ -1,45 +1,21 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { loadScript, loadStyle } from '../controls'; | ||
import { loadAsset } from '../controls'; | ||
|
||
describe( 'controls', () => { | ||
const scriptAsset = 'http://www.wordpress.org/plugins/fakeasset.js'; | ||
const styleAsset = 'http://www.wordpress.org/plugins/fakeasset.css'; | ||
describe( 'loadAsset', () => { | ||
const script = document.createElement( 'script' ); | ||
const style = document.createElement( 'link' ); | ||
|
||
describe( 'loadScript', () => { | ||
it( 'should return a Promise when loading a script', () => { | ||
const result = loadScript( scriptAsset ); | ||
const result = loadAsset( script ); | ||
expect( typeof result.then ).toBe( 'function' ); | ||
} ); | ||
|
||
it( 'should reject when no script is given', async () => { | ||
expect.assertions( 1 ); | ||
const result = loadScript( '' ); | ||
await expect( result ).rejects.toThrow( Error ); | ||
} ); | ||
|
||
it( 'should reject when a non-js file is given', async () => { | ||
const result = loadScript( styleAsset ); | ||
await expect( result ).rejects.toThrow( Error ); | ||
} ); | ||
} ); | ||
|
||
describe( 'loadStyle', () => { | ||
it( 'should return a Promise when loading a style', () => { | ||
const result = loadStyle( styleAsset ); | ||
const result = loadAsset( style ); | ||
expect( typeof result.then ).toBe( 'function' ); | ||
} ); | ||
|
||
it( 'should reject when no style is given', async () => { | ||
expect.assertions( 1 ); | ||
const result = loadStyle( '' ); | ||
await expect( result ).rejects.toThrow( Error ); | ||
} ); | ||
|
||
it( 'should reject when a non-css file is given', async () => { | ||
const result = loadStyle( scriptAsset ); | ||
await expect( result ).rejects.toThrow( Error ); | ||
} ); | ||
} ); | ||
} ); |
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