-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reset and hasValue logic, add tests, update label
- Loading branch information
1 parent
6c9bbce
commit d9d87ba
Showing
4 changed files
with
78 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
import { | ||
backgroundPositionToCoords, | ||
coordsToBackgroundPosition, | ||
} from '../background'; | ||
|
||
describe( 'backgroundPositionToCoords', () => { | ||
it( 'should return the correct coordinates for a percentage value using 2-value syntax', () => { | ||
expect( backgroundPositionToCoords( '25% 75%' ) ).toEqual( { | ||
x: 0.25, | ||
y: 0.75, | ||
} ); | ||
} ); | ||
|
||
it( 'should return the correct coordinates for a percentage using 1-value syntax', () => { | ||
expect( backgroundPositionToCoords( '50%' ) ).toEqual( { | ||
x: 0.5, | ||
y: 0.5, | ||
} ); | ||
} ); | ||
|
||
it( 'should return undefined coords in given an empty value', () => { | ||
expect( backgroundPositionToCoords( '' ) ).toEqual( { | ||
x: undefined, | ||
y: undefined, | ||
} ); | ||
} ); | ||
|
||
it( 'should return undefined coords in given a string that cannot be converted', () => { | ||
expect( backgroundPositionToCoords( 'apples' ) ).toEqual( { | ||
x: undefined, | ||
y: undefined, | ||
} ); | ||
} ); | ||
} ); | ||
|
||
describe( 'coordsToBackgroundPosition', () => { | ||
it( 'should return the correct background position for a set of coordinates', () => { | ||
expect( coordsToBackgroundPosition( { x: 0.25, y: 0.75 } ) ).toBe( | ||
'25% 75%' | ||
); | ||
} ); | ||
|
||
it( 'should return undefined if no coordinates are provided', () => { | ||
expect( coordsToBackgroundPosition( {} ) ).toBeUndefined(); | ||
} ); | ||
} ); |
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