Simplify solution and unit-tests

This commit is contained in:
IvanZosimov 2023-04-07 12:04:33 +02:00
parent 36571034fa
commit 3fb9de05e9
8 changed files with 4358 additions and 4384 deletions

View file

@ -1,6 +1,10 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import {isVersionSatisfies, isCacheFeatureAvailable} from '../src/util';
import {
convertVersionToSemver,
isVersionSatisfies,
isCacheFeatureAvailable
} from '../src/util';
jest.mock('@actions/cache');
jest.mock('@actions/core');
@ -63,3 +67,16 @@ describe('isCacheFeatureAvailable', () => {
expect(isCacheFeatureAvailable()).toBe(true);
});
});
describe('convertVersionToSemver', () => {
it.each([
['12', '12'],
['12.0', '12.0'],
['12.0.2', '12.0.2'],
['12.0.2.1', '12.0.2+1'],
['12.0.2.1.0', '12.0.2+1.0']
])('%s -> %s', (input: string, expected: string) => {
const actual = convertVersionToSemver(input);
expect(actual).toBe(expected);
});
});