2024-03-07 12:10:36 +01:00
|
|
|
import { expect, tap } from '@push.rocks/tapbundle';
|
2022-04-26 14:44:53 +02:00
|
|
|
import * as smartversion from '../ts/index.js';
|
2017-08-17 16:15:47 +02:00
|
|
|
|
|
|
|
|
tap.test('should create a valid SmartVersion', async () => {
|
2021-04-26 07:16:26 +00:00
|
|
|
const localSmartVersion = new smartversion.SmartVersion('3.2.1');
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(localSmartVersion).toBeInstanceOf(smartversion.SmartVersion);
|
2017-08-18 10:58:00 +02:00
|
|
|
// tslint:disable-next-line:no-unused-expression
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(localSmartVersion.greaterThanString('4.0.0')).toBeFalse();
|
2017-08-18 10:58:00 +02:00
|
|
|
// tslint:disable-next-line:no-unused-expression
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(localSmartVersion.greaterThanString('3.0.0')).toBeTrue();
|
2017-08-18 10:58:00 +02:00
|
|
|
// tslint:disable-next-line:no-unused-expression
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(localSmartVersion.lessThanString('v4.0.0')).toBeTrue();
|
2017-08-18 10:58:00 +02:00
|
|
|
// tslint:disable-next-line:no-unused-expression
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(localSmartVersion.lessThanString('v3.0.0')).toBeFalse();
|
2018-09-02 12:26:04 +02:00
|
|
|
});
|
2017-08-18 10:58:00 +02:00
|
|
|
|
2021-04-26 07:16:26 +00:00
|
|
|
tap.test('should create a valid SmartVersion', async () => {
|
|
|
|
|
const localSmartVersion = smartversion.SmartVersion.fromFuzzyString('4');
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(localSmartVersion).toBeInstanceOf(smartversion.SmartVersion);
|
2021-04-26 07:16:26 +00:00
|
|
|
console.log(localSmartVersion.versionString);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should create a valid SmartVersion', async () => {
|
|
|
|
|
const localSmartVersion = smartversion.SmartVersion.fromFuzzyString('4.x');
|
|
|
|
|
const bestMatch = localSmartVersion.getBestMatch(['4.0.1', '4.7.5', '4.3.0']);
|
|
|
|
|
console.log(bestMatch);
|
2022-04-26 14:44:53 +02:00
|
|
|
expect(bestMatch).toEqual('4.7.5');
|
2021-04-26 07:16:26 +00:00
|
|
|
});
|
|
|
|
|
|
2022-04-26 14:44:53 +02:00
|
|
|
tap.test('should create a patch version', async () => {
|
|
|
|
|
const versInstance = smartversion.SmartVersion.fromFuzzyString('1.2.3');
|
|
|
|
|
const newVersion = versInstance.getNewPatchVersion();
|
|
|
|
|
console.log(newVersion.versionString);
|
|
|
|
|
})
|
|
|
|
|
|
2024-03-07 13:22:24 +01:00
|
|
|
export const runTestPromise = tap.start();
|