Created
January 20, 2017 20:12
-
-
Save louisptremblay/dac2f742c7b74abce5209d38ff10f104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
const proxyquire = require('proxyquire').noCallThru(); | |
const requestsMock = { get: null }; | |
const Tools = proxyquire('../Tools', { | |
'../../../utils/api/requests': requestsMock, | |
}); | |
describe('Tools', () => { | |
describe('fileExists', () => { | |
it('should return true if the file exists', () => { | |
requestsMock.get = () => ({ 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', () => { | |
requestsMock.get = () => ({ 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