Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mock from 'mock-fs'
- import fs from 'fs'
- import fileHandler from '../utils/fileHandler'
- beforeEach(() => {
- // Creates an in-memory file system
- mock({
- '/test': {
- 'note.md': 'hello world!'
- }
- })
- })
- afterEach(() => {
- mock.restore()
- })
- it('saves a file given it\'s contents', () => {
- expect.assertions(1)
- fileHandler.saveFileSync('/test/note2.md', 'ciao world!')
- expect(fs.existsSync('/test/note.md')).toBeTruthy();
- })
- it('loads a file from disk', () => {
- expect.assertions(1)
- const actual = fileHandler.loadFileSync('/test/note.md')
- expect(actual).toBe('hello world!')
- })
Add Comment
Please, Sign In to add comment