1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/util/semver.test.ts

24 lines
1.1 KiB
TypeScript
Raw Normal View History

import { mustParseStrictSemVer, parseStrictSemVer } from './semver';
test('parseStrictSemVer', () => {
expect(parseStrictSemVer('')).toEqual(null);
expect(parseStrictSemVer('v')).toEqual(null);
expect(parseStrictSemVer('v1')).toEqual(null);
expect(parseStrictSemVer('v1.2.3')).toEqual(null);
expect(parseStrictSemVer('=1.2.3')).toEqual(null);
expect(parseStrictSemVer('1.2')).toEqual(null);
expect(parseStrictSemVer('1.2.3.4')).toEqual(null);
expect(parseStrictSemVer('1.2.3')!.version).toEqual('1.2.3');
});
test('mustParseSemVer', () => {
expect(() => mustParseStrictSemVer('').version).toThrow();
expect(() => mustParseStrictSemVer('1').version).toThrow();
expect(() => mustParseStrictSemVer('1.2').version).toThrow();
expect(() => mustParseStrictSemVer('v1.2').version).toThrow();
expect(() => mustParseStrictSemVer('v1.2.3').version).toThrow();
expect(() => mustParseStrictSemVer('=1.2.3').version).toThrow();
expect(() => mustParseStrictSemVer('1.2.3.4').version).toThrow();
expect(mustParseStrictSemVer('1.2.3').version).toEqual('1.2.3');
});