mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
|
import { ClientSpecService } from './client-spec-service';
|
||
|
import getLogger from '../../test/fixtures/no-logger';
|
||
|
|
||
|
test('ClientSpecService validation', async () => {
|
||
|
const service = new ClientSpecService({ getLogger });
|
||
|
const fn = service.versionSupportsSpec.bind(service);
|
||
|
|
||
|
expect(fn('segments', undefined)).toEqual(false);
|
||
|
expect(fn('segments', '')).toEqual(false);
|
||
|
|
||
|
expect(() => fn('segments', 'a')).toThrow('Invalid prefix');
|
||
|
expect(() => fn('segments', '1.2')).toThrow('Invalid SemVer');
|
||
|
expect(() => fn('segments', 'v1.2.3')).toThrow('Invalid prefix');
|
||
|
expect(() => fn('segments', '=1.2.3')).toThrow('Invalid prefix');
|
||
|
expect(() => fn('segments', '1.2.3.4')).toThrow('Invalid SemVer');
|
||
|
});
|
||
|
|
||
|
test('ClientSpecService segments', async () => {
|
||
|
const service = new ClientSpecService({ getLogger });
|
||
|
const fn = service.versionSupportsSpec.bind(service);
|
||
|
|
||
|
expect(fn('segments', '0.0.0')).toEqual(false);
|
||
|
expect(fn('segments', '1.0.0')).toEqual(false);
|
||
|
expect(fn('segments', '4.1.9')).toEqual(false);
|
||
|
|
||
|
expect(fn('segments', '4.2.0')).toEqual(true);
|
||
|
expect(fn('segments', '4.2.1')).toEqual(true);
|
||
|
expect(fn('segments', '5.0.0')).toEqual(true);
|
||
|
});
|