summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/peer-deps-invalid.js
blob: c28736550176e2812f96f76a050f0327e2dee5a2 (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
36
37
38
39
40
41
42
43
44
45
46
var common = require('../common-tap.js')
var fs = require("fs")
var path = require("path")
var test = require("tap").test
var rimraf = require("rimraf")
var npm = require("../../")
var mr = require("npm-registry-mock")
var pkg = __dirname + "/peer-deps-invalid"

var okFile = fs.readFileSync(path.join(pkg, "file-ok.js"), "utf8")
var failFile = fs.readFileSync(path.join(pkg, "file-fail.js"), "utf8")

test("installing dependencies that have conflicting peerDependencies", function (t) {
  rimraf.sync(pkg + "/node_modules")
  rimraf.sync(pkg + "/cache")
  process.chdir(pkg)

  var customMocks = {
    "get": {
      "/ok.js": [200, okFile],
      "/invalid.js": [200, failFile]
    }
  }
  mr({port: common.port, mocks: customMocks}, function (s) { // create mock registry.
    npm.load({
      cache: pkg + "/cache",
      registry: common.registry
    }, function () {
      npm.commands.install([], function (err) {
        if (!err) {
          t.fail("No error!")
        } else {
          t.equal(err.code, "EPEERINVALID")
        }
        t.end()
        s.close() // shutdown mock registry.
      })
    })
  })
})

test("cleanup", function (t) {
  rimraf.sync(pkg + "/node_modules")
  rimraf.sync(pkg + "/cache")
  t.end()
})