smartversion/test/test.ts

31 lines
1.3 KiB
TypeScript
Raw Normal View History

import { expect, tap } from '@pushrocks/tapbundle';
import * as smartversion from '../ts/index';
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');
expect(localSmartVersion).to.be.instanceof(smartversion.SmartVersion);
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.greaterThanString('4.0.0')).to.be.false;
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.greaterThanString('3.0.0')).to.be.true;
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.lessThanString('v4.0.0')).to.be.true;
2017-08-18 08:58:00 +00:00
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.lessThanString('v3.0.0')).to.be.false;
});
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');
expect(localSmartVersion).to.be.instanceof(smartversion.SmartVersion);
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);
expect(bestMatch).to.equal('4.7.5');
});
tap.start();