2020-10-05 17:07:35 +00:00
|
|
|
import { moduleFor, test } from 'ember-qunit';
|
|
|
|
import repo from 'consul-ui/tests/helpers/repo';
|
|
|
|
|
|
|
|
moduleFor('service:repository/topology', 'Integration | Repository | topology', {
|
|
|
|
// Specify the other units that are required for this test.
|
|
|
|
integration: true,
|
|
|
|
});
|
|
|
|
const dc = 'dc-1';
|
|
|
|
const id = 'slug';
|
2020-10-09 18:39:16 +00:00
|
|
|
const kind = '';
|
2020-10-05 17:07:35 +00:00
|
|
|
test('findBySlug returns the correct data for item endpoint', function(assert) {
|
|
|
|
return repo(
|
|
|
|
'Service',
|
|
|
|
'findBySlug',
|
|
|
|
this.subject(),
|
|
|
|
function retrieveStub(stub) {
|
2020-10-09 18:39:16 +00:00
|
|
|
return stub(`/v1/internal/ui/service-topology/${id}?dc=${dc}&${kind}`, {
|
2020-10-05 17:07:35 +00:00
|
|
|
CONSUL_DISCOVERY_CHAIN_COUNT: 1,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
2020-10-09 18:39:16 +00:00
|
|
|
return service.findBySlug(id, kind, dc);
|
2020-10-05 17:07:35 +00:00
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
|
|
|
const result = expected(function(payload) {
|
|
|
|
return Object.assign(
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
Datacenter: dc,
|
|
|
|
uid: `["default","${dc}","${id}"]`,
|
|
|
|
meta: {
|
|
|
|
cacheControl: undefined,
|
|
|
|
cursor: undefined,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
payload
|
|
|
|
);
|
|
|
|
});
|
|
|
|
assert.equal(actual.Datacenter, result.Datacenter);
|
|
|
|
assert.equal(actual.uid, result.uid);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|