summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/install-order.js
blob: 80b3f6f45ebf77b3025690dbb239dd70afcf7d42 (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
54
55
56
57
58
59
60
61
62
63
64
'use strict'
var test = require('tap').test
var sortActions = require('../../lib/install/diff-trees.js').sortActions
var top = {
  location: '/',
  package: {},
  requiredBy: [],
  requires: [a, b],
  isTop: true
}
var a = {
  location: '/a',
  package: {},
  requiredBy: [],
  requires: [c],
  isTop: false,
  userRequired: false,
  existing: false,
  parent: top
}
var b = {
  location: '/b',
  package: {},
  requiredBy: [],
  requires: [c],
  isTop: false,
  userRequired: false,
  existing: false,
  parent: top
}
var c = {
  location: '/c',
  package: {},
  requiredBy: [a, b],
  requires: [],
  isTop: false,
  userRequired: false,
  existing: false,
  parent: top
}

test('install-order when installing deps', function (t) {
  var plain = [
    ['add', a],
    ['add', b],
    ['add', c]]
  var sorted = [
    ['add', c],
    ['add', a],
    ['add', b]]
  t.isDeeply(sortActions(plain), sorted)
  t.end()
})

test('install-order when not installing deps', function (t) {
  var plain = [
    ['add', a],
    ['add', b]]
  var sorted = [
    ['add', a],
    ['add', b]]
  t.isDeeply(sortActions(plain), sorted)
  t.end()
})