Files
pnpm/pkg-manager/core/test/api.ts
2024-10-24 16:59:55 +02:00

36 lines
1.2 KiB
TypeScript

import * as pnpm from '@pnpm/core'
import { testDefaults } from './utils'
test('API', () => {
expect(typeof pnpm.install).toBe('function')
})
// TODO: some sort of this validation might need to exist
// maybe a new property should be introduced
// this seems illogical as even though all save types are false,
// the dependency will be saved
test.skip('install fails when all saving types are false', async () => {
try {
await pnpm.install({}, testDefaults({ save: false, saveDev: false, saveOptional: false }))
throw new Error('installation should have failed')
} catch (err: any) { // eslint-disable-line
expect(err.message).toBe('Cannot install with save/saveDev/saveOptional all being equal false')
}
})
test('install fails on optional = true but production = false', async () => {
try {
const opts = testDefaults({
include: {
dependencies: false,
devDependencies: false,
optionalDependencies: true,
},
})
await pnpm.install({}, opts)
throw new Error('installation should have failed')
} catch (err: any) { // eslint-disable-line
expect(err.message).toBe('Optional dependencies cannot be installed without production dependencies')
}
})