0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/packages/utils/test/middleware-utils.spec.ts
Juan Picado 0c7b19b192
chore: migrate vitest packages (#4777)
* chore: migrate core to vitest

* chore: migrate url module

* chore: migrate tarball package

* chore: migrate loader package

* chore: migrate hook package

* chore: migrate signature package

* chore: migrate utils package
2024-08-03 19:39:22 +02:00

20 lines
766 B
TypeScript

import { describe, expect, test } from 'vitest';
import { getVersionFromTarball } from '../src/middleware-utils';
describe('Utilities', () => {
describe('getVersionFromTarball', () => {
test('should get the right version', () => {
const simpleName = 'test-name-4.2.12.tgz';
const complexName = 'test-5.6.4-beta.2.tgz';
const otherComplexName = 'test-3.5.0-6.tgz';
expect(getVersionFromTarball(simpleName)).toEqual('4.2.12');
expect(getVersionFromTarball(complexName)).toEqual('5.6.4-beta.2');
expect(getVersionFromTarball(otherComplexName)).toEqual('3.5.0-6');
});
test("should don'n fall at incorrect tarball name", () => {
expect(getVersionFromTarball('incorrectName')).toBeUndefined();
});
});
});