-
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.
add test case for ratioToNumber function
- Loading branch information
1 parent
001391b
commit 18c2045
Showing
2 changed files
with
23 additions
and
1 deletion.
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
22 changes: 22 additions & 0 deletions
22
packages/block-editor/src/components/aspect-ratio-dropdown/test/index.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,22 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ratioToNumber } from '../'; | ||
|
||
test( 'ratioToNumber', () => { | ||
expect( ratioToNumber( '1/1' ) ).toBe( 1 ); | ||
expect( ratioToNumber( '1' ) ).toBe( 1 ); | ||
expect( ratioToNumber( '11/11' ) ).toBe( 1 ); | ||
expect( ratioToNumber( '16/9' ) ).toBe( 16 / 9 ); | ||
expect( ratioToNumber( '4/3' ) ).toBe( 4 / 3 ); | ||
expect( ratioToNumber( '3/2' ) ).toBe( 3 / 2 ); | ||
expect( ratioToNumber( '2/1' ) ).toBe( 2 ); | ||
expect( ratioToNumber( '1/2' ) ).toBe( 1 / 2 ); | ||
expect( ratioToNumber( '2/3' ) ).toBe( 2 / 3 ); | ||
expect( ratioToNumber( '3/4' ) ).toBe( 3 / 4 ); | ||
expect( ratioToNumber( '9/16' ) ).toBe( 9 / 16 ); | ||
expect( ratioToNumber( '1/16' ) ).toBe( 1 / 16 ); | ||
expect( ratioToNumber( '16/1' ) ).toBe( 16 ); | ||
expect( ratioToNumber( '1/9' ) ).toBe( 1 / 9 ); | ||
expect( ratioToNumber( 'auto' ) ).toBe( NaN ); | ||
} ); |