Last active
January 15, 2020 20:44
-
-
Save schipiga/c294ccb34c1a967f3ba703e9ff8327a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const myModule = rehire("./myModule", { | |
"fs": { existsSync: () => true }, | |
}); | |
suite("myModule", () => { | |
afterChunk(() => { | |
myModule.__reset__(); | |
}); | |
test("mock internal function", () => { | |
chunk("get it", () => { | |
const _summarize = myModule.__get__('_summarize'); | |
expect(_summarize(1, 2)).to.be.equal(3); | |
}); | |
chunk("set it", () => { | |
myModule.__set__('_summarize', () => 5); | |
expect(myModule.summarize(1, 2)).to.be.equal(5); | |
}); | |
}); | |
test("mock third-party module", () => { | |
chunk(() => { | |
expect(myModule.isPathExists('/bla/bla/bla')).to.be.true; | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment