mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-31 05:22:00 -04:00
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import { getOptionsFromRootManifest } from '../lib/getOptionsFromRootManifest'
|
|
|
|
test('getOptionsFromRootManifest() should read "resolutions" field for compatibility with Yarn', () => {
|
|
const options = getOptionsFromRootManifest({
|
|
resolutions: {
|
|
foo: '1.0.0',
|
|
},
|
|
})
|
|
expect(options.overrides).toStrictEqual({ foo: '1.0.0' })
|
|
})
|
|
|
|
test('getOptionsFromRootManifest() should read "overrides" field', () => {
|
|
const options = getOptionsFromRootManifest({
|
|
pnpm: {
|
|
overrides: {
|
|
foo: '1.0.0',
|
|
},
|
|
},
|
|
})
|
|
expect(options.overrides).toStrictEqual({ foo: '1.0.0' })
|
|
})
|
|
|
|
test('getOptionsFromRootManifest() Support $ in overrides by dependencies', () => {
|
|
const options = getOptionsFromRootManifest({
|
|
dependencies: {
|
|
foo: '1.0.0',
|
|
},
|
|
pnpm: {
|
|
overrides: {
|
|
foo: '$foo',
|
|
},
|
|
},
|
|
})
|
|
expect(options.overrides).toStrictEqual({ foo: '1.0.0' })
|
|
})
|
|
|
|
test('getOptionsFromRootManifest() Support $ in overrides by devDependencies', () => {
|
|
const options = getOptionsFromRootManifest({
|
|
devDependencies: {
|
|
foo: '1.0.0',
|
|
},
|
|
pnpm: {
|
|
overrides: {
|
|
foo: '$foo',
|
|
},
|
|
},
|
|
})
|
|
expect(options.overrides).toStrictEqual({ foo: '1.0.0' })
|
|
})
|
|
|
|
test('getOptionsFromRootManifest() Support $ in overrides by dependencies and devDependencies', () => {
|
|
const options = getOptionsFromRootManifest({
|
|
dependencies: {
|
|
foo: '1.0.0',
|
|
},
|
|
devDependencies: {
|
|
foo: '2.0.0',
|
|
},
|
|
pnpm: {
|
|
overrides: {
|
|
foo: '$foo',
|
|
},
|
|
},
|
|
})
|
|
expect(options.overrides).toStrictEqual({ foo: '1.0.0' })
|
|
})
|
|
|
|
test('getOptionsFromRootManifest() throws an error if cannot resolve an override version reference', () => {
|
|
expect(() => getOptionsFromRootManifest({
|
|
dependencies: {
|
|
bar: '1.0.0',
|
|
},
|
|
pnpm: {
|
|
overrides: {
|
|
foo: '$foo',
|
|
},
|
|
},
|
|
})).toThrow('Cannot resolve version $foo in overrides. The direct dependencies don\'t have dependency "foo".')
|
|
})
|