open-consul/ui-v2/tests/integration/adapters/coordinate/response-test.js

24 lines
817 B
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { get } from 'consul-ui/tests/helpers/api';
module('Integration | Adapter | coordinate | response', function(hooks) {
setupTest(hooks);
const dc = 'dc-1';
test('handleResponse returns the correct data for list endpoint', function(assert) {
const adapter = this.owner.lookup('adapter:coordinate');
const request = {
url: `/v1/coordinate/nodes?dc=${dc}`,
};
return get(request.url).then(function(payload) {
const expected = payload.map(item =>
Object.assign({}, item, {
Datacenter: dc,
uid: `["${dc}","${item.Node}"]`,
})
);
const actual = adapter.handleResponse(200, {}, payload, request);
assert.deepEqual(actual, expected);
});
});
});