c98130cc08
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
77 lines
2 KiB
JavaScript
77 lines
2 KiB
JavaScript
import { moduleFor, test } from 'ember-qunit';
|
|
import repo from 'consul-ui/tests/helpers/repo';
|
|
import { get } from '@ember/object';
|
|
const NAME = 'node';
|
|
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
|
// Specify the other units that are required for this test.
|
|
integration: true,
|
|
});
|
|
|
|
const dc = 'dc-1';
|
|
const id = 'token-name';
|
|
const now = new Date().getTime();
|
|
const nspace = 'default';
|
|
test('findByDatacenter returns the correct data for list endpoint', function(assert) {
|
|
get(this.subject(), 'store').serializerFor(NAME).timestamp = function() {
|
|
return now;
|
|
};
|
|
return repo(
|
|
'Node',
|
|
'findAllByDatacenter',
|
|
this.subject(),
|
|
function retrieveStub(stub) {
|
|
return stub(`/v1/internal/ui/nodes?dc=${dc}`, {
|
|
CONSUL_NODE_COUNT: '100',
|
|
});
|
|
},
|
|
function performTest(service) {
|
|
return service.findAllByDatacenter(dc);
|
|
},
|
|
function performAssertion(actual, expected) {
|
|
assert.deepEqual(
|
|
actual,
|
|
expected(function(payload) {
|
|
return payload.map(item =>
|
|
Object.assign({}, item, {
|
|
SyncTime: now,
|
|
Datacenter: dc,
|
|
uid: `["${nspace}","${dc}","${item.ID}"]`,
|
|
})
|
|
);
|
|
})
|
|
);
|
|
}
|
|
);
|
|
});
|
|
test('findBySlug returns the correct data for item endpoint', function(assert) {
|
|
return repo(
|
|
'Node',
|
|
'findBySlug',
|
|
this.subject(),
|
|
function(stub) {
|
|
return stub(`/v1/internal/ui/node/${id}?dc=${dc}`);
|
|
},
|
|
function(service) {
|
|
return service.findBySlug(id, dc);
|
|
},
|
|
function(actual, expected) {
|
|
assert.deepEqual(
|
|
actual,
|
|
expected(function(payload) {
|
|
const item = payload;
|
|
return Object.assign({}, item, {
|
|
Datacenter: dc,
|
|
uid: `["${nspace}","${dc}","${item.ID}"]`,
|
|
meta: {
|
|
cacheControl: undefined,
|
|
cursor: undefined,
|
|
dc: dc,
|
|
nspace: nspace,
|
|
},
|
|
});
|
|
})
|
|
);
|
|
}
|
|
);
|
|
});
|