initial commit

This commit is contained in:
2021-12-10 12:03:04 +00:00
commit c46c7ddbf0
3643 changed files with 582794 additions and 0 deletions

View File

@ -0,0 +1,26 @@
/**
* Internal dependencies
*/
import { isWpVersion } from '..';
import { allSettings } from '../settings-init';
describe( 'isWpVersion', () => {
it.each`
version | operator | result
${ '5.3-beta1' } | ${ '<' } | ${ true }
${ '5.3' } | ${ '=' } | ${ true }
${ '5.3-beta12-235' } | ${ '<' } | ${ true }
${ '5.3-rc1' } | ${ '>' } | ${ false }
${ '5.3-rc12-235' } | ${ '<' } | ${ true }
${ '5.3.1' } | ${ '>' } | ${ true }
${ '5.4-beta1' } | ${ '>' } | ${ true }
`(
'should return $result when $version is the current wpVersion ' +
'and `5.3` is the version compared using `$operator`',
( { version, operator, result } ) => {
// eslint-disable-next-line
allSettings[ 'wpVersion' ] = version;
expect( isWpVersion( '5.3', operator ) ).toBe( result );
}
);
} );

View File

@ -0,0 +1,20 @@
/**
* Internal dependencies
*/
import { getSetting } from '../utils';
import { ADMIN_URL } from '../default-constants';
describe( 'getSetting', () => {
it( 'returns provided default for non available setting', () => {
expect( getSetting( 'nada', 'really nada' ) ).toBe( 'really nada' );
} );
it( 'returns expected value for existing setting', () => {
expect( getSetting( 'adminUrl', 'not this' ) ).toEqual( ADMIN_URL );
} );
it( "returns expected value for existing setting even if it's a falsy value", () => {
expect( getSetting( 'currentUserIsAdmin', true ) ).toBe( false );
} );
it( 'filters value via provided filter callback', () => {
expect( getSetting( 'some value', 'default', () => 42 ) ).toBe( 42 );
} );
} );