Files
pnpm/resolving/npm-resolver/test/whichVersionIsPinned.test.ts
Zoltan Kochan 29ab905c21 fix: preserve catalog version range policy on update (#12416)
A named catalog whose name parses as a version (e.g. catalog:express4-21)
had its range policy overridden by pnpm update because whichVersionIsPinned
misread the catalog: reference in the previous specifier as a pinned
version. The catalog reference carries no pinning of its own, so the prefix
from the catalog entry is now preserved.

Closes https://github.com/pnpm/pnpm/issues/10321
2026-06-15 11:58:29 +02:00

26 lines
812 B
TypeScript

import { expect, test } from '@jest/globals'
import { whichVersionIsPinned } from '../lib/whichVersionIsPinned.js'
test.each([
['^1.0.0', 'major'],
['~1.0.0', 'minor'],
['1.0.0', 'patch'],
['*', 'none'],
['workspace:^1.0.0', 'major'],
['npm:foo@1.0.0', 'patch'],
['npm:@foo/foo@1.0.0', 'patch'],
['npm:foo@^1.0.0', 'major'],
['npm:@foo/foo@^1.0.0', 'major'],
['npm:@pnpm.e2e/qar@100.0.0', 'patch'],
['jsr:@foo/foo@1.0.0', 'patch'],
['jsr:foo@^1.0.0', 'major'],
['catalog:', undefined],
['catalog:default', undefined],
['catalog:foo', undefined],
// A catalog name that parses as a version must not be treated as a pin.
['catalog:express4-21', undefined],
])('whichVersionIsPinned()', (spec, expectedResult) => {
expect(whichVersionIsPinned(spec)).toEqual(expectedResult)
})