Function
mock
(sandbox: Sinon.SinonSandbox, readFail?: boolean, writeFail?: boolean)
Source from the content-addressed store, hash-verified
| 34 | } |
| 35 | let sandbox: Sinon.SinonSandbox |
| 36 | const mock = function (sandbox: Sinon.SinonSandbox, readFail?: boolean, writeFail?: boolean) { |
| 37 | sandbox.stub(fs, 'readFile').callsFake(async (path, options) => { |
| 38 | void path |
| 39 | void options |
| 40 | if (readFail) { |
| 41 | throw new Error() |
| 42 | } |
| 43 | return 'privKey' |
| 44 | }) |
| 45 | sandbox.stub(fs, 'writeFile').callsFake(async (path, options) => { |
| 46 | void path |
| 47 | void options |
| 48 | if (writeFail) { |
| 49 | throw new Error() |
| 50 | } |
| 51 | return |
| 52 | }) |
| 53 | } |
| 54 | |
| 55 | beforeEach(() => { |
| 56 | sandbox = Sinon.createSandbox() |
Tested by
no test coverage detected