Files
pnpm/deps/status/test/assertLockfilesEqual.test.ts
Zoltan Kochan 1c8c4e49f5 style: add eslint-plugin-simple-import-sort (#10947)
Add eslint-plugin-simple-import-sort to enforce consistent import ordering:
- Node.js builtins first
- External packages second
- Relative imports last
- Named imports sorted alphabetically within each statement
2026-03-13 02:02:38 +01:00

82 lines
2.1 KiB
TypeScript

import { LOCKFILE_VERSION } from '@pnpm/constants'
import type { LockfileObject } from '@pnpm/lockfile.fs'
import type { ProjectId } from '@pnpm/types'
import { assertLockfilesEqual } from '../src/assertLockfilesEqual.js'
test('if wantedLockfile does not have any specifier, currentLockfile is allowed to be null', () => {
assertLockfilesEqual(null, {
lockfileVersion: LOCKFILE_VERSION,
importers: {
['.' as ProjectId]: {
specifiers: {},
},
},
}, '<LOCKFILE_DIR>')
})
test('should throw if wantedLockfile has specifiers but currentLockfile is null', () => {
expect(() => assertLockfilesEqual(null, {
lockfileVersion: LOCKFILE_VERSION,
importers: {
['.' as ProjectId]: {
specifiers: {
foo: '^1.0.0',
},
dependencies: {
foo: '1.0.1',
},
},
},
}, '<LOCKFILE_DIR>')).toThrow('Project . requires dependencies but none was installed.')
})
test('should not throw if wantedLockfile and currentLockfile are equal', () => {
const lockfile = (): LockfileObject => ({
lockfileVersion: LOCKFILE_VERSION,
importers: {
['.' as ProjectId]: {
specifiers: {
foo: '^1.0.0',
},
dependencies: {
foo: '1.0.1',
},
},
},
})
assertLockfilesEqual(lockfile(), lockfile(), '<LOCKFILE_DIR>')
})
test('should throw if wantedLockfile and currentLockfile are not equal', () => {
expect(() => assertLockfilesEqual(
{
lockfileVersion: LOCKFILE_VERSION,
importers: {
['.' as ProjectId]: {
specifiers: {
foo: '^1.0.0',
},
dependencies: {
foo: '1.0.1',
},
},
},
},
{
lockfileVersion: LOCKFILE_VERSION,
importers: {
['.' as ProjectId]: {
specifiers: {
foo: '^1.0.0',
},
dependencies: {
foo: '1.1.0',
},
},
},
},
'<LOCKFILE_DIR>')
).toThrow('The installed dependencies in the modules directory is not up-to-date with the lockfile in <LOCKFILE_DIR>.')
})