Skip to content

Commit

Permalink
Refactor peer test.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Aug 3, 2024
1 parent 5765fce commit ed807ec
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
44 changes: 35 additions & 9 deletions test/peer.test.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
import path from 'path'
import ncu from '../src/'
import chaiSetup from './helpers/chaiSetup'

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',
})
})

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')
})

Expand Down
7 changes: 0 additions & 7 deletions test/test-data/peer-lock/package.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/test-data/peer-update/package.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/test-data/peer/package.json

This file was deleted.

0 comments on commit ed807ec

Please sign in to comment.