summaryrefslogtreecommitdiff
path: root/deps/node/deps/npm/test/tap/update-path.js
blob: 1578669a253fb95bbc2d96db5c8ba387316efa22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict'
var test = require('tap').test
var requireInject = require('require-inject')

var mockNpm = {
  config: {
    get: function (key) {
      return false
    }
  },
  commands: {
    outdated: function (args, silent, cb) {
      cb(null, [
        [{path: '/incorrect', parent: {path: '/correct'}}, 'abc', '1.0.0', '1.1.0', '1.1.0', '^1.1.0']
      ])
    }
  }
}

// What we're testing here is that updates use the parent module's path to
// install from.
test('update', function (t) {
  var update = requireInject('../../lib/update.js', {
    '../../lib/npm.js': mockNpm,
    '../../lib/install.js': {
      'Installer': function (where, dryrun, args) {
        t.is(where, '/correct', 'We should be installing to the parent of the modules being updated')
        this.run = function (cb) { cb() }
      }
    }
  })
  update(['abc'], function () {
    t.end()
  })
})