From ed807ec83855fd6cec83c22affb62acbd5f7e696 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Sat, 3 Aug 2024 18:39:13 +0000 Subject: [PATCH] Refactor peer test. --- test/peer.test.ts | 44 ++++++++++++++++++++----- test/test-data/peer-lock/package.json | 7 ---- test/test-data/peer-update/package.json | 7 ---- test/test-data/peer/package.json | 7 ---- 4 files changed, 35 insertions(+), 30 deletions(-) delete mode 100644 test/test-data/peer-lock/package.json delete mode 100644 test/test-data/peer-update/package.json delete mode 100644 test/test-data/peer/package.json diff --git a/test/peer.test.ts b/test/peer.test.ts index cb959187e..96fe5d70e 100644 --- a/test/peer.test.ts +++ b/test/peer.test.ts @@ -1,4 +1,3 @@ -import path from 'path' import ncu from '../src/' import chaiSetup from './helpers/chaiSetup' @@ -6,24 +5,44 @@ chaiSetup() describe('peer dependencies', function () { it('peer dependencies are ignored by default', async () => { - const cwd = path.join(__dirname, 'test-data/peer/') - const upgrades = await ncu({ cwd }) + const upgrades = await ncu({ + packageData: { + dependencies: { + 'ncu-test-peer': '1.0.0', + 'ncu-test-return-version': '1.0.0', + }, + }, + }) upgrades!.should.deep.equal({ 'ncu-test-return-version': '2.0.0', }) }) it('peer dependencies are checked when using option peer', async () => { - const cwd = path.join(__dirname, 'test-data/peer/') - const upgrades = await ncu({ cwd, peer: true }) + const upgrades = await ncu({ + peer: true, + packageData: { + dependencies: { + 'ncu-test-peer': '1.0.0', + 'ncu-test-return-version': '1.0.0', + }, + }, + }) upgrades!.should.deep.equal({ 'ncu-test-return-version': '1.1.0', }) }) it('peer dependencies are checked iteratively when using option peer', async () => { - const cwd = path.join(__dirname, 'test-data/peer-update/') - const upgrades = await ncu({ cwd, peer: true }) + const upgrades = await ncu({ + peer: true, + packageData: { + dependencies: { + 'ncu-test-peer-update': '1.0.0', + 'ncu-test-return-version': '1.0.0', + }, + }, + }) upgrades!.should.deep.equal({ 'ncu-test-return-version': '1.1.0', 'ncu-test-peer-update': '1.1.0', @@ -31,8 +50,15 @@ describe('peer dependencies', function () { }) it('circular peer dependencies are ignored', async () => { - const cwd = path.join(__dirname, 'test-data/peer-lock/') - const upgrades = await ncu({ cwd, peer: true }) + const upgrades = await ncu({ + peer: true, + packageData: { + dependencies: { + '@vitest/ui': '^1.3.1', + vitest: '^1.3.1', + }, + }, + }) upgrades!.should.contain.keys('@vitest/ui', 'vitest') }) diff --git a/test/test-data/peer-lock/package.json b/test/test-data/peer-lock/package.json deleted file mode 100644 index f3bb0bed5..000000000 --- a/test/test-data/peer-lock/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "license": "MIT", - "dependencies": { - "@vitest/ui": "^1.3.1", - "vitest": "^1.3.1" - } -} diff --git a/test/test-data/peer-update/package.json b/test/test-data/peer-update/package.json deleted file mode 100644 index efe7a1697..000000000 --- a/test/test-data/peer-update/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "license": "MIT", - "dependencies": { - "ncu-test-peer-update": "1.0.0", - "ncu-test-return-version": "1.0.0" - } -} diff --git a/test/test-data/peer/package.json b/test/test-data/peer/package.json deleted file mode 100644 index 67143713a..000000000 --- a/test/test-data/peer/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "license": "MIT", - "dependencies": { - "ncu-test-peer": "1.0.0", - "ncu-test-return-version": "1.0.0" - } -}