macos-defaults/build/__mocks__/fs.js

16 lines
391 B
JavaScript
Raw Normal View History

2020-11-27 12:45:16 +00:00
const fs = jest.genMockFromModule('fs')
const result = {}
fs.mkdirSync = jest.fn()
fs.writeFileSync = jest.fn((path, content) => {
result[path] = content
})
fs.copyFileSync = jest.fn((origin, destination) => {
result[destination] = `copied:${origin}`
})
2020-11-27 12:45:16 +00:00
fs.readFakeFileSync = jest.fn((path) => result[path])
fs.readFileSync = jest.requireActual('fs').readFileSync
module.exports = fs