summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/outdated-depth.js
blob: 112f363aa50823145fbf3debf3e386f339c22ff9 (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
47
48
49
50
51
52
53
var common = require("../common-tap")
  , path = require("path")
  , test = require("tap").test
  , rimraf = require("rimraf")
  , npm = require("../../")
  , mr = require("npm-registry-mock")
  , pkg = path.resolve(__dirname, "outdated-depth")
  , cache = path.resolve(pkg, "cache")
  , nodeModules = path.resolve(pkg, "node_modules")

function cleanup () {
  rimraf.sync(nodeModules)
  rimraf.sync(cache)
}

test("outdated depth zero", function (t) {
  var expected = [
    pkg,
    "underscore",
    "1.3.1",
    "1.3.1",
    "1.5.1",
    "1.3.1"
  ]

  process.chdir(pkg)

  mr(common.port, function (s) {
    npm.load({
      cache: cache
    , loglevel: "silent"
    , registry: common.registry
    , depth: 0
    }
    , function () {
        npm.install(".", function (er) {
          if (er) throw new Error(er)
          npm.outdated(function (err, d) {
            if (err) throw new Error(err)
            t.deepEqual(d[0], expected)
            s.close()
            t.end()
          })
        })
      }
    )
  })
})

test("cleanup", function (t) {
  cleanup()
  t.end()
})