Add .npmrc unit and E2E tests

This commit is contained in:
Peter McEvoy 2024-10-20 12:32:44 -04:00
parent aca7b64a59
commit b3a9c64ba8
3 changed files with 5 additions and 1 deletions

View File

@ -159,7 +159,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version-file: node-version-file:
[.nvmrc, .tool-versions, .tool-versions-node, package.json] [.nvmrc, .tool-versions, .tool-versions-node, package.json, .npmrc]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup node from node version file - name: Setup node from node version file

1
__tests__/data/.npmrc Normal file
View File

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

View File

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