Skip to content

Commit

Permalink
unit tests for checkPeer option
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Apr 5, 2021
1 parent 25b5d7a commit b9d90d2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
const chaiString = require('chai-string')
const ncu = require('../lib/')
const { npm: spawnNpm } = require('../lib/package-managers/npm')

chai.use(chaiAsPromised)
chai.use(chaiString)
Expand Down Expand Up @@ -708,4 +709,25 @@ describe('run', function () {

})

describe('peer dependencies', () => {
const peerPath = path.join(__dirname, '/peer/')

it('peer dependencies of installed packages are ignored by default', async () => {
await spawnNpm('install', {}, { cwd: peerPath })
const upgrades = await ncu.run({ cwd: peerPath })
upgrades.should.deep.equal({
'ncu-test-return-version': '2.0.0'
})
})

it('peer dependencies of installed packages are checked when using option checkPeer', async () => {
await spawnNpm('install', {}, { cwd: peerPath })
const upgrades = await ncu.run({ cwd: peerPath, checkPeer: true })
upgrades.should.deep.equal({
'ncu-test-return-version': '1.1.0'
})
})

})

})
6 changes: 6 additions & 0 deletions test/peer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"ncu-test-peer": "1.0.0",
"ncu-test-return-version": "1.0.0"
}
}

0 comments on commit b9d90d2

Please sign in to comment.