Skip to content

Instantly share code, notes, and snippets.

@louisptremblay
Created January 20, 2017 20:08
Show Gist options
  • Save louisptremblay/cf008055aea392b5bfa4f5481c01d624 to your computer and use it in GitHub Desktop.
Save louisptremblay/cf008055aea392b5bfa4f5481c01d624 to your computer and use it in GitHub Desktop.
let Tools;
let getMock;
describe('Tools', () => {
beforeEach(() => {
Tools = proxyquire('../Tools', {
'../../../utils/api/requests': { get: getMock },
});
});
describe('fileExists', () => {
it('should return true if the file exists', () => {
getMock = () => ({ status: 200, json: () => Promise.resolve('exists') });
const exists = Tools.fileExists('foobar.txt');
return exists.then(v => expect(v).to.be.true);
});
it('should return false if the file doesnt exist', () => {
getMock = () => ({ status: 400 });
const exists = Tools.fileExists('foobar.txt');
return exists.then(v => expect(v).to.be.false);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment