• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var readInstalled = require("../read-installed.js")
2var test = require("tap").test
3var json = require("../package.json")
4var path = require("path")
5var known = [].concat(Object.keys(json.dependencies)
6  , Object.keys(json.optionalDependencies)
7  , Object.keys(json.devDependencies)).sort()
8
9test("make sure that it works with depth=0", function (t) {
10  readInstalled(path.join(__dirname, "../"), {
11    depth: 0
12  }, function (er, map) {
13    t.notOk(er, "er should be bull")
14    t.ok(map, "map should be data")
15    if (er) return console.error(er.stack || er.message)
16    // Exclude self from dependencies when depth = 0
17    delete map.dependencies[json.name]
18    var subdeps = Object.keys(map.dependencies).reduce(function(acc, dep) {
19      // Exclude self from dependencies when depth = current depth
20      delete map.dependencies[dep].dependencies[dep]
21      acc += Object.keys(map.dependencies[dep].dependencies).length;
22      return acc;
23    }, 0);
24    t.equal(subdeps, 0, "there should be no sub dependencies")
25    t.end()
26  })
27})
28