From ff0f4b6812a8b4151248b9384bef8fbf11096415 Mon Sep 17 00:00:00 2001
From: Peter McEvoy <git@mcevoypeter.com>
Date: Sun, 20 Oct 2024 12:32:44 -0400
Subject: [PATCH] Add .npmrc unit and E2E tests

---
 .github/workflows/versions.yml | 2 +-
 __tests__/data/.npmrc          | 1 +
 __tests__/main.test.ts         | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 __tests__/data/.npmrc

diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml
index b51ba8b5..2794055f 100644
--- a/.github/workflows/versions.yml
+++ b/.github/workflows/versions.yml
@@ -158,7 +158,7 @@ jobs:
       matrix:
         os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
         node-version-file:
-          [.nvmrc, .tool-versions, .tool-versions-node, package.json]
+          [.nvmrc, .tool-versions, .tool-versions-node, package.json, .npmrc]
     steps:
       - uses: actions/checkout@v4
       - name: Setup node from node version file
diff --git a/__tests__/data/.npmrc b/__tests__/data/.npmrc
new file mode 100644
index 00000000..911d4fc2
--- /dev/null
+++ b/__tests__/data/.npmrc
@@ -0,0 +1 @@
+use-node-version=20.0.0
diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts
index 501741a6..17537394 100644
--- a/__tests__/main.test.ts
+++ b/__tests__/main.test.ts
@@ -103,10 +103,13 @@ describe('main tests', () => {
       ${''}                                        | ${''}
       ${'unknown format'}                          | ${'unknown format'}
       ${'  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": {"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);