Skip to content
Snippets Groups Projects
Unverified Commit 9c28522f authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

tests: Refactor tests for node versioning scheme (#11837)

parent 044de81a
No related branches found
Tags 32.119.2
No related merge requests found
...@@ -9,49 +9,47 @@ describe('versioning/node/index', () => { ...@@ -9,49 +9,47 @@ describe('versioning/node/index', () => {
afterEach(() => { afterEach(() => {
DateTime.local = dtLocal; DateTime.local = dtLocal;
}); });
it('returns normalized newVersion', () => {
expect( test.each`
nodever.getNewValue({ currentValue | rangeStrategy | currentVersion | newVersion | expected
currentValue: '1.0.0', ${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'v1.1.0'} | ${'1.1.0'}
rangeStrategy: 'replace', ${'~8.0.0'} | ${'replace'} | ${'8.0.2'} | ${'v8.2.0'} | ${'~8.2.0'}
currentVersion: '1.0.0', `(
newVersion: 'v1.1.0', 'getNewValue($currentValue, $rangeStrategy, $currentVersion, $newVersion, $expected) === $expected',
}) ({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {
).toEqual('1.1.0'); const res = nodever.getNewValue({
}); currentValue,
it('returns range', () => { rangeStrategy,
expect( currentVersion,
nodever.getNewValue({ newVersion,
currentValue: '~8.0.0', });
rangeStrategy: 'replace', expect(res).toBe(expected);
currentVersion: '8.0.2', }
newVersion: 'v8.2.0', );
})
).toEqual('~8.2.0'); describe('isStable', () => {
});
it('isStable', () => {
const t1 = DateTime.fromISO('2020-09-01'); const t1 = DateTime.fromISO('2020-09-01');
const t2 = DateTime.fromISO('2021-06-01'); const t2 = DateTime.fromISO('2021-06-01');
[
['16.0.0', t1, false],
['15.0.0', t1, false],
['14.9.0', t1, false],
['14.0.0', t2, true],
['12.0.3', t1, true],
['v12.0.3', t1, true],
['12.0.3a', t1, false],
['11.0.0', t1, false],
['10.0.0', t1, true],
['10.0.999', t1, true],
['10.1.0', t1, true],
['10.0.0a', t1, false], test.each`
['9.0.0', t1, false], version | time | expected
].forEach(([version, time, result]) => { ${'16.0.0'} | ${t1} | ${false}
${'15.0.0'} | ${t1} | ${false}
${'14.9.0'} | ${t1} | ${false}
${'14.0.0'} | ${t2} | ${true}
${'12.0.3'} | ${t1} | ${true}
${'v12.0.3'} | ${t1} | ${true}
${'12.0.3a'} | ${t1} | ${false}
${'11.0.0'} | ${t1} | ${false}
${'10.0.0'} | ${t1} | ${true}
${'10.0.999'} | ${t1} | ${true}
${'10.1.0'} | ${t1} | ${true}
${'10.0.0a'} | ${t1} | ${false}
${'9.0.0'} | ${t1} | ${false}
`('isStable("$version") === $expected', ({ version, time, expected }) => {
DateTime.local = (...args) => DateTime.local = (...args) =>
args.length ? dtLocal.apply(DateTime, args) : time; args.length ? dtLocal.apply(DateTime, args) : time;
expect(isStable(version as string)).toBe(result); expect(isStable(version as string)).toBe(expected);
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment