Skip to content

Commit

Permalink
Forgot to move the tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Sep 13, 2024
1 parent b876924 commit e541285
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Internal dependencies
*/

import { backgroundPositionToCoords, coordsToBackgroundPosition } from '../';

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();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,7 @@
* Internal dependencies
*/

import {
backgroundPositionToCoords,
coordsToBackgroundPosition,
hasBackgroundImageValue,
} from '../background-panel';

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();
} );
} );
import { hasBackgroundImageValue } from '../background-panel';

describe( 'hasBackgroundImageValue', () => {
it( 'should return `true` when id and url exist', () => {
Expand Down

0 comments on commit e541285

Please sign in to comment.