Skip to content

Commit

Permalink
add tests to assert rewiremock compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed May 3, 2019
1 parent 3c50b83 commit 8688843
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 1 deletion.
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"require-inject": "^1.4.4",
"requizzle": "^0.2.1",
"rewire": "^4.0.1",
"rewiremock": "^3.13.6",
"semver": "^5.7.0",
"sinon": "^7.3.2",
"sleep": "^5.2.4",
Expand Down
4 changes: 4 additions & 0 deletions test/fixture/scenario/rewiremock/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { extname } from "path"
import b from "./b.js"

export default () => "a" + b + extname("")
1 change: 1 addition & 0 deletions test/fixture/scenario/rewiremock/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty module.
3 changes: 3 additions & 0 deletions test/fixture/scenario/rewiremock/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import a from "./a.js"

export default () => a()
22 changes: 22 additions & 0 deletions test/fixture/scenario/rewiremock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import assert from "assert"
import rewiremock from "rewiremock"

const a = rewiremock
.proxy("./a.js", {
path: {
extname: () => "c"
},
"./b.js": "b"
})

assert.strictEqual(a.default(), "abc")

const c = rewiremock.proxy("./c.js", {
path: {
extname: () => "c"
},
"./b.js": "b"
})

assert.strictEqual(c.default(), "abc")

8 changes: 7 additions & 1 deletion test/scenario-tests.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SemVer from "semver"

import assert from "assert"
import execa from "execa"
import fs from "fs-extra"
Expand Down Expand Up @@ -185,6 +184,13 @@ describe("scenario tests", function () {
], envAuto)
)

it("should work with rewiremock", () => {
node([
"-r", pkgPath,
path.resolve("fixture/scenario/rewiremock")
], envAuto)
})

it("should work with sinon", () =>
node([
path.resolve("fixture/scenario/sinon")
Expand Down

0 comments on commit 8688843

Please sign in to comment.