File size: 566 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { toValidId } from '../id-helpers';

describe( 'toValidId', () => {
	const testCases = [
		[ undefined, undefined ],
		[ null, undefined ],
		[ 0, undefined ],
		[ '0', undefined ],
		[ false, undefined ],
		[ true, undefined ],
		[ 1, 1 ],
		[ '1', 1 ],
		[ 4, 4 ],
		[ '4', 4 ],
		[ '4.8', undefined ],
		[ 1 / 0, undefined ],
	];

	testCases.forEach( function ( testCase ) {
		const [ provided, expected ] = testCase;
		test( `'${ provided }' should yield '${ expected }'`, () => {
			expect( toValidId( provided ) ).toEqual( expected );
		} );
	} );
} );