This commit is contained in:
Kyle Leonhard 2025-04-02 16:06:41 -04:00 committed by GitHub
commit a300359e24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 657 additions and 5 deletions

View file

@ -2,7 +2,7 @@ Files located in data directory are used only for testing purposes.
## Here the list of files in the data directory
- `.nvmrc`, `.tools-versions` and `package.json` are used to test node-version-file logic
- `.nvmrc`, `.tools-versions`, `package.json` and `.npmrc` are used to test node-version-file logic
- `package-lock.json`, `pnpm-lock.yaml` and `yarn.lock` are used to test cache logic
- `versions-manifest.json` is used for unit testing to check downloading Node.js versions from the node-versions repository.
- `node-dist-index.json` is used for unit testing to check downloading Node.js versions from the official site. The file was constructed from https://nodejs.org/dist/index.json

1
__tests__/data/.npmrc Normal file
View file

@ -0,0 +1 @@
use-node-version=20.0.0

View file

@ -103,10 +103,14 @@ describe('main tests', () => {
${''} | ${''}
${'unknown format'} | ${'unknown format'}
${' 14.1.0 '} | ${'14.1.0'}
${'use-node-version=lts/iron'} | ${'lts/iron'}
${'use-node-version=23.10.0'} | ${'23.10.0'}
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'}
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
${'{}'} | ${null}
${'[section]use-node-version=16'} | ${null}
${'[section]\nuse-node-version=20'} | ${null}
`.it('parses "$contents"', ({contents, expected}) => {
const existsSpy = jest.spyOn(fs, 'existsSync');
existsSpy.mockImplementation(() => true);