Merge branch 'develop' into ICU-350-users-crud

This commit is contained in:
Susmitha Girumala authored and GitHub committed 2020-06-29 10:40:09 -04:00
commit f52539aabd
11 files changed
+163 -3

No files matched your search

@@ -3,9 +3,12 @@ import { setupTest } from 'ember-qunit';
import config from 'ember-get-config';
import RESTAdapter from '@ember-data/adapter/rest';
import { InvalidError } from '@ember-data/adapter/error';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { Response } from 'miragejs';
module('Unit | Adapter | application', function (hooks) {
setupTest(hooks);
setupMirage(hooks);
test('its namespace is equal to the configured namespace', function (assert) {
assert.expect(2);
@@ -24,12 +27,23 @@ module('Unit | Adapter | application', function (hooks) {
assert.expect(1);
const adapter = this.owner.lookup('adapter:application');
// TODO this is icky, should be changed to a spy or stub
const originalAjax = RESTAdapter.prototype.ajax;
RESTAdapter.prototype.ajax = (url, type) => {
assert.equal(type, 'PATCH');
RESTAdapter.prototype.ajax = originalAjax;
};
adapter.ajax('/', 'PUT');
});
test('it prenormalizes "empty" responses into a form that the fetch-manager will not reject', async function (assert) {
assert.expect(1);
const adapter = this.owner.lookup('adapter:project');
const store = this.owner.lookup('service:store');
this.server.get('/v1/projects', () => new Response({}));
const prenormalized = await adapter.findAll(store, {modelName: 'project'}, null, []);
assert.deepEqual(prenormalized, {items: []});
});
test('it correctly identifies 400 responses as invalid', function (assert) {
assert.expect(2);
const adapter = this.owner.lookup('adapter:application');