mirror of
https://github.com/pnpm/pnpm.git
synced 2026-06-28 01:45:30 -04:00
* fix: respect pmOnFail ignore in self-update * fix: preserve devEngines lockfile writes * fix: restore unrelated whitespace hunks --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
36 lines
1.9 KiB
TypeScript
36 lines
1.9 KiB
TypeScript
import { describe, expect, test } from '@jest/globals'
|
|
import { shouldPersistLockfile } from '@pnpm/config.reader'
|
|
|
|
describe('shouldPersistLockfile', () => {
|
|
test('devEngines.packageManager persists unless onFail is ignore', () => {
|
|
expect(shouldPersistLockfile({ version: '9.3.0', fromDevEngines: true })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '11.0.0', fromDevEngines: true })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '12.0.0', fromDevEngines: true })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '>=9.0.0', fromDevEngines: true })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '>=9.0.0', fromDevEngines: true, onFail: 'ignore' })).toBe(false)
|
|
})
|
|
|
|
test('packageManager field with pnpm v11 or older does not persist', () => {
|
|
expect(shouldPersistLockfile({ version: '9.3.0' })).toBe(false)
|
|
expect(shouldPersistLockfile({ version: '10.0.0' })).toBe(false)
|
|
expect(shouldPersistLockfile({ version: '11.0.0' })).toBe(false)
|
|
expect(shouldPersistLockfile({ version: '11.0.0-rc.1' })).toBe(false)
|
|
})
|
|
|
|
test('packageManager field with pnpm v12 or newer persists', () => {
|
|
expect(shouldPersistLockfile({ version: '12.0.0' })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '12.5.3' })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '13.0.0' })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '100.0.0' })).toBe(true)
|
|
expect(shouldPersistLockfile({ version: '12.0.0', onFail: 'ignore' })).toBe(false)
|
|
})
|
|
|
|
test('missing or invalid version does not persist', () => {
|
|
expect(shouldPersistLockfile({ version: undefined })).toBe(false)
|
|
expect(shouldPersistLockfile({ version: 'not-a-version' })).toBe(false)
|
|
// Ranges are not valid for the legacy packageManager field. Its parser
|
|
// rejects them, but the persistence gate still treats them as non-pinning.
|
|
expect(shouldPersistLockfile({ version: '^12.0.0' })).toBe(false)
|
|
})
|
|
})
|