-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(fixtures): add tests for FixturesLoader
- Loading branch information
Raphaël Benitte
authored and
Raphaël Benitte
committed
Jul 2, 2017
1 parent
f84ca4b
commit 56b5d32
Showing
5 changed files
with
316 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
|
||
const fs = jest.genMockFromModule('fs') | ||
|
||
let mockFiles = {} | ||
|
||
const __setMockFiles = _mockFiles => { | ||
mockFiles = _mockFiles | ||
} | ||
|
||
const readFile = (file, cb) => { | ||
const mockedContent = mockFiles[file] | ||
if (mockedContent !== undefined) return cb(null, mockedContent) | ||
cb(new Error(`File does not exist (${file})`)) | ||
} | ||
|
||
fs.__setMockFiles = __setMockFiles | ||
fs.readFile = readFile | ||
|
||
module.exports = fs |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const glob = jest.genMockFromModule('glob') | ||
|
||
let mockedResults = {} | ||
|
||
module.exports = (pattern, cb) => { | ||
if (pattern === '__defineMocks') { | ||
mockedResults = cb | ||
return | ||
} | ||
|
||
const mockedResult = mockedResults[pattern] | ||
if (mockedResult === undefined) return cb(null, []) | ||
cb(null, mockedResult) | ||
} |
Oops, something went wrong.