open-consul/ui-v2/tests/integration/serializers/nspace-test.js
John Cowen 31f36ce096 ui: Namespace Support (#6639)
Adds namespace support to the UI:

1. Namespace CRUD/management
2. Show Namespace in relevant areas (intentions, upstreams)
3. Main navigation bar improvements
4. Logic/integration to interact with a new `internal/acl/authorize` endpoint
2019-12-18 12:26:47 +00:00

46 lines
1.5 KiB
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { get } from 'consul-ui/tests/helpers/api';
// Nspace don't need any datacenter or nspace, and don't
module('Integration | Serializer | nspace', function(hooks) {
setupTest(hooks);
test('respondForQuery returns the correct data for list endpoint', function(assert) {
const serializer = this.owner.lookup('serializer:nspace');
const request = {
url: `/v1/namespaces`,
};
return get(request.url).then(function(payload) {
const expected = payload.map(item => Object.assign({}, item, {}));
const actual = serializer.respondForQuery(function(cb) {
const headers = {};
const body = payload;
return cb(headers, body);
}, {});
assert.deepEqual(actual, expected);
});
});
test('respondForQueryRecord returns the correct data for item endpoint', function(assert) {
const serializer = this.owner.lookup('serializer:nspace');
const id = 'slug';
const request = {
url: `/v1/namespace/${id}`,
};
return get(request.url).then(function(payload) {
// Namespace items don't currently get META attached
const expected = payload;
const actual = serializer.respondForQueryRecord(
function(cb) {
const headers = {};
const body = payload;
return cb(headers, body);
},
{
id: id,
}
);
assert.deepEqual(actual, expected);
});
});
});