1'use strict' 2/* eslint-disable no-use-before-define */ 3var test = require('tap').test 4var sortActions = require('../../lib/install/diff-trees.js').sortActions 5var top = { 6 location: '/', 7 package: {}, 8 requiredBy: [], 9 requires: [a, b], 10 isTop: true 11} 12var a = { 13 location: '/a', 14 package: {}, 15 requiredBy: [], 16 requires: [c], 17 isTop: false, 18 userRequired: false, 19 existing: false, 20 parent: top 21} 22var b = { 23 location: '/b', 24 package: {}, 25 requiredBy: [], 26 requires: [c], 27 isTop: false, 28 userRequired: false, 29 existing: false, 30 parent: top 31} 32var c = { 33 location: '/c', 34 package: {}, 35 requiredBy: [a, b], 36 requires: [], 37 isTop: false, 38 userRequired: false, 39 existing: false, 40 parent: top 41} 42 43test('install-order when installing deps', function (t) { 44 var plain = [ 45 ['add', a], 46 ['add', b], 47 ['add', c]] 48 var sorted = [ 49 ['add', c], 50 ['add', a], 51 ['add', b]] 52 t.isDeeply(sortActions(plain), sorted) 53 t.end() 54}) 55 56test('install-order when not installing deps', function (t) { 57 var plain = [ 58 ['add', a], 59 ['add', b]] 60 var sorted = [ 61 ['add', a], 62 ['add', b]] 63 t.isDeeply(sortActions(plain), sorted) 64 t.end() 65}) 66