smartversion/test/test.both.ts

37 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-03-07 11:10:36 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
2022-04-26 12:44:53 +00:00
import * as smartversion from '../ts/index.js';
2017-08-17 14:15:47 +00: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 12:44:53 +00:00
expect(localSmartVersion).toBeInstanceOf(smartversion.SmartVersion);
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
2022-04-26 12:44:53 +00:00
expect(localSmartVersion.greaterThanString('4.0.0')).toBeFalse();
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
2022-04-26 12:44:53 +00:00
expect(localSmartVersion.greaterThanString('3.0.0')).toBeTrue();
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
2022-04-26 12:44:53 +00:00
expect(localSmartVersion.lessThanString('v4.0.0')).toBeTrue();
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
2022-04-26 12:44:53 +00:00
expect(localSmartVersion.lessThanString('v3.0.0')).toBeFalse();
});
2017-08-18 08:58:00 +00: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 12:44:53 +00: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 12:44:53 +00:00
expect(bestMatch).toEqual('4.7.5');
2021-04-26 07:16:26 +00:00
});
2022-04-26 12:44:53 +00: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 12:22:24 +00:00
export const runTestPromise = tap.start();