Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import { expect } from 'chai';
  2. const proxyquire = require('proxyquire').noCallThru();
  3.  
  4. const requestsMock = { get: null };
  5.  
  6. const Tools = proxyquire('../Tools', {
  7. '../../../utils/api/requests': requestsMock,
  8. });
  9.  
  10. describe('Tools', () => {
  11. describe('fileExists', () => {
  12. it('should return true if the file exists', () => {
  13. requestsMock.get = () => ({ 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. requestsMock.get = () => ({ 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