Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
4,447 additions
and
378 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 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 |
---|---|---|
|
@@ -118,3 +118,5 @@ dist | |
*.torrent | ||
torrents/ | ||
config.js | ||
output/ | ||
input/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,32 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
|
||
const fs = jest.createMockFromModule("fs"); | ||
|
||
// This is a custom function that our tests can use during setup to specify | ||
// what the files on the "mock" filesystem should look like when any of the | ||
// `fs` APIs are used. | ||
let mockFiles = Object.create(null); | ||
function __setMockFiles(newMockFiles) { | ||
mockFiles = Object.create(null); | ||
for (const file in newMockFiles) { | ||
const dir = path.dirname(file); | ||
|
||
if (!mockFiles[dir]) { | ||
mockFiles[dir] = []; | ||
} | ||
mockFiles[dir].push(path.basename(file)); | ||
} | ||
} | ||
|
||
// A custom version of `readdirSync` that reads from the special mocked out | ||
// file list set via __setMockFiles | ||
function readdirSync(directoryPath) { | ||
return mockFiles[directoryPath] || []; | ||
} | ||
|
||
fs.__setMockFiles = __setMockFiles; | ||
fs.readdirSync = readdirSync; | ||
|
||
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,13 @@ | ||
"use strict"; | ||
|
||
const path = jest.createMockFromModule("path"); | ||
|
||
// A custom version of `readdirSync` that reads from the special mocked out | ||
// file list set via __setMockFiles | ||
function join(...args) { | ||
return args.join("/"); | ||
} | ||
|
||
path.join = join; | ||
|
||
module.exports = path; |
Oops, something went wrong.