2018-02-21 14:41:05 -08:00
|
|
|
import { getJSON, postJSON, deleteJSON, putJSON, getHeaders } from 'wherehows-web/utils/api/fetcher';
|
2017-09-19 13:32:04 -07:00
|
|
|
import { module, test } from 'qunit';
|
2017-11-30 10:33:07 -08:00
|
|
|
import sinon from 'sinon';
|
2017-09-19 13:32:04 -07:00
|
|
|
|
2017-11-30 10:33:07 -08:00
|
|
|
module('Unit | Utility | api/fetcher', {
|
|
|
|
beforeEach() {
|
|
|
|
this.xhr = sinon.useFakeXMLHttpRequest();
|
|
|
|
},
|
2017-09-19 13:32:04 -07:00
|
|
|
|
2017-11-30 10:33:07 -08:00
|
|
|
afterEach() {
|
|
|
|
this.xhr.restore();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('each http request function exists', function(assert) {
|
2018-02-21 14:41:05 -08:00
|
|
|
[getJSON, postJSON, deleteJSON, putJSON, getHeaders].forEach(httpRequest =>
|
2017-11-30 10:33:07 -08:00
|
|
|
assert.ok(typeof httpRequest === 'function', `${httpRequest} is a function`)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('each http request function returns a Promise / thennable', function(assert) {
|
|
|
|
[getJSON, postJSON, deleteJSON, putJSON, getHeaders].forEach(httpRequest =>
|
|
|
|
assert.ok(typeof httpRequest({}).then === 'function', `${httpRequest} returns a Promise object or thennable`)
|
|
|
|
);
|
2017-09-19 13:32:04 -07:00
|
|
|
});
|