Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. let Tools;
  2. let getMock;
  3.  
  4. describe('Tools', () => {
  5. beforeEach(() => {
  6. Tools = proxyquire('../Tools', {
  7. '../../../utils/api/requests': { get: getMock },
  8. });
  9. });
  10.  
  11. describe('fileExists', () => {
  12. it('should return true if the file exists', () => {
  13. getMock = () => ({ status: 200, json: () => Promise.resolve('exists') });
  14. const exists = Tools.fileExists('foobar.txt');
  15. return exists.then(v => expect(v).to.be.true);
  16. });
  17.  
  18. it('should return false if the file doesnt exist', () => {
  19. getMock = () => ({ status: 400 });
  20. const exists = Tools.fileExists('foobar.txt');
  21. return exists.then(v => expect(v).to.be.false);
  22. });
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement