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
olav 7e3f0329ab
refactor: avoid inlining segments for supported clients (#1640)
* refactor: add semver lib types

* refactor: avoid inlining segments for supported clients

* refactor: fix FeatureController tests

* refactor: use spec version instead of client version

* refactor: improve header validation errors
2022-06-02 14:07:46 +02:00

24 lines
1.1 KiB
TypeScript

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');
});