2019-10-11 15:29:27 +00:00
|
|
|
/**
|
2019-11-08 16:30:11 +00:00
|
|
|
* Internal dependencies
|
2019-10-11 15:29:27 +00:00
|
|
|
*/
|
2020-12-15 15:10:24 +00:00
|
|
|
import { isWpVersion, setSetting } from '..';
|
2019-10-11 15:29:27 +00:00
|
|
|
|
2020-12-15 15:10:24 +00:00
|
|
|
describe( 'isWpVersion', () => {
|
2020-08-18 09:40:08 +00:00
|
|
|
let initial = true;
|
2019-10-11 15:29:27 +00:00
|
|
|
it.each`
|
2020-09-07 17:31:10 +00:00
|
|
|
version | operator | result
|
2020-12-15 15:10:24 +00:00
|
|
|
${ '5.3-beta1' } | ${ '<' } | ${ true }
|
2020-09-07 17:31:10 +00:00
|
|
|
${ '5.3' } | ${ '=' } | ${ true }
|
2020-12-15 15:10:24 +00:00
|
|
|
${ '5.3-beta12-235' } | ${ '<' } | ${ true }
|
|
|
|
${ '5.3-rc1' } | ${ '>' } | ${ false }
|
|
|
|
${ '5.3-rc12-235' } | ${ '<' } | ${ true }
|
|
|
|
${ '5.3.1' } | ${ '>' } | ${ true }
|
|
|
|
${ '5.4-beta1' } | ${ '>' } | ${ true }
|
2019-10-11 15:29:27 +00:00
|
|
|
`(
|
|
|
|
'should return $result when $version is the current wpVersion ' +
|
|
|
|
'and `5.3` is the version compared using `$operator`',
|
|
|
|
( { version, operator, result } ) => {
|
|
|
|
setSetting( 'wpVersion', version );
|
2020-08-18 09:40:08 +00:00
|
|
|
// deprecated caches messages once per session, so we only check
|
|
|
|
// console warn on initial call.
|
|
|
|
if ( initial ) {
|
|
|
|
expect( console ).toHaveWarned();
|
|
|
|
}
|
|
|
|
initial = false;
|
2020-12-15 15:10:24 +00:00
|
|
|
expect( isWpVersion( '5.3', operator ) ).toBe( result );
|
2019-10-11 15:29:27 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|