nx/packages/js/src/generators/release-version/utils/resolve-version-spec.spec.ts
James Henry 9116c29c18
feat(core): initial implementation of nx release (#19110)
Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
2023-09-18 15:11:44 -04:00

84 lines
1.9 KiB
TypeScript

import { join } from 'path';
import { resolveVersionSpec } from './resolve-version-spec';
describe('resolveVersionSpec()', () => {
it('should work for specific name and spec', () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.4',
'^1.0.0',
'/test/packages/packageB'
)
).toEqual('^1.0.0');
});
it('should work for a workspace spec', () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.4',
'workspace:^1.0.0',
'/test/packages/packageB'
)
).toEqual('^1.0.0');
});
describe('with a workspace alias', () => {
it('should work for a * workspace alias', () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.4',
'workspace:*',
'/test/packages/packageB'
)
).toEqual('1.0.4');
});
it('should work for a ^ workspace alias', () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.4',
'workspace:^',
'/test/packages/packageB'
)
).toEqual('^1.0.4');
});
it('should work for a ~ workspace alias', () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.4',
'workspace:~',
'/test/packages/packageB'
)
).toEqual('~1.0.4');
});
});
it('should for a file reference', async () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.0',
'file:../projectB',
'/packages/projectB'
)
).toEqual(expect.stringContaining(join('/packages/projectB')));
});
it('should work for a yarn classic style link reference', async () => {
expect(
resolveVersionSpec(
'projectA',
'1.0.0',
'link:../projectB',
'/packages/fuck'
)
).toEqual(expect.stringContaining(join('/packages/projectB')));
});
});