Guest User

Untitled

a guest
Jul 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import mock from 'mock-fs'
  2. import fs from 'fs'
  3. import fileHandler from '../utils/fileHandler'
  4.  
  5. beforeEach(() => {
  6. // Creates an in-memory file system
  7. mock({
  8. '/test': {
  9. 'note.md': 'hello world!'
  10. }
  11. })
  12. })
  13.  
  14. afterEach(() => {
  15. mock.restore()
  16. })
  17.  
  18. it('saves a file given it\'s contents', () => {
  19. expect.assertions(1)
  20. fileHandler.saveFileSync('/test/note2.md', 'ciao world!')
  21. expect(fs.existsSync('/test/note.md')).toBeTruthy();
  22. })
  23.  
  24. it('loads a file from disk', () => {
  25. expect.assertions(1)
  26. const actual = fileHandler.loadFileSync('/test/note.md')
  27.  
  28. expect(actual).toBe('hello world!')
  29. })
Add Comment
Please, Sign In to add comment