Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Fix mock scenario tests in Node 12.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed May 6, 2019
1 parent 2207949 commit 04cdca8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/fixture/scenario/mock-require-inject/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from "assert"
import createNamespace from "../../../create-namespace.js"
import * as fsNs from "fs"
import mock from "mock-require"
import * as pathNs from "path"
Expand Down Expand Up @@ -49,39 +50,39 @@ mock("util", "./util.js")
import("./load.js")
.then((ns) => {
const expected = {
fs: mockFs,
fs: createNamespace(mockFs),
path: pathNs,
real1: {
real1: createNamespace({
default: "mock1"
},
real2: mockReal2,
real3: {
}),
real2: createNamespace(mockReal2),
real3: createNamespace({
default: "real3"
},
util: mockUtil
}),
util: createNamespace(mockUtil)
}

assert.deepEqual(ns, expected)
assert.deepEqual(ns, createNamespace(expected))

const exported = requireInject("./load.js", {
path: mockPath,
"./real3.js": mockReal3
})

expected.path = mockPath
expected.real3 = mockReal3
expected.path = createNamespace(mockPath)
expected.real3 = createNamespace(mockReal3)

assert.deepEqual(exported, expected)
})
.then(() =>
Promise
.all([
import("fs")
.then((ns) => assert.deepEqual(ns, mockFs)),
.then((ns) => assert.deepEqual(ns, createNamespace(mockFs))),
import("path")
.then((ns) => assert.strictEqual(ns, pathNs)),
import("util")
.then((ns) => assert.deepEqual(ns, mockUtil))
.then((ns) => assert.deepEqual(ns, createNamespace(mockUtil)))
])
)
.then(() => {
Expand Down

0 comments on commit 04cdca8

Please sign in to comment.