UNPKG

926 BPlain TextView Raw
1import { maxSatisfying } from '../../';
2
3// maxSatisfying(versions, range): Return the highest version in the list that
4// satisfies the range, or null if none of them do.
5
6describe('test maxSatisfying', () => {
7 it('maxSatisfying(versions, range)', () => {
8 expect(maxSatisfying(['1.2.3', '1.2.4'], '~> 1.2')).toBe('1.2.4');
9 expect(maxSatisfying(['1.2.3', '1.2.4', '1.2.5'], '~> 1.2, <= 1.2.4')).toBe('1.2.4');
10 expect(maxSatisfying(['1.2.4', '1.2.3'], '~> 1.2')).toBe('1.2.4');
11 expect(maxSatisfying(['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~> 1.2.3')).toBe('1.2.6',);
12 expect(
13 maxSatisfying(
14 [
15 '1.1.0',
16 '1.2.0',
17 '1.2.1',
18 '1.3.0',
19 '2.0.0b1',
20 '2.0.0b2',
21 '2.0.0b3',
22 '2.0.0',
23 '2.1.0',
24 ], '~> 2.0.0',
25 )).toBe('2.0.0');
26 expect(maxSatisfying(['1.2.3', '1.2.4'], '> 3.2')).toBeNull();
27 })
28});