2019-12-17 19:27:28 +00:00
|
|
|
import { moduleFor, test } from 'ember-qunit';
|
|
|
|
import repo from 'consul-ui/tests/helpers/repo';
|
|
|
|
|
2021-09-15 18:50:11 +00:00
|
|
|
moduleFor('service:repository/discovery-chain', 'Integration | Service | discovery-chain', {
|
2019-12-17 19:27:28 +00:00
|
|
|
// Specify the other units that are required for this test.
|
|
|
|
integration: true,
|
|
|
|
});
|
|
|
|
const dc = 'dc-1';
|
|
|
|
const id = 'slug';
|
|
|
|
test('findBySlug returns the correct data for item endpoint', function(assert) {
|
|
|
|
return repo(
|
|
|
|
'Service',
|
|
|
|
'findBySlug',
|
|
|
|
this.subject(),
|
|
|
|
function retrieveStub(stub) {
|
|
|
|
return stub(`/v1/discovery-chain/${id}?dc=${dc}`, {
|
|
|
|
CONSUL_DISCOVERY_CHAIN_COUNT: 1,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
2021-02-23 08:56:42 +00:00
|
|
|
return service.findBySlug({ id, dc });
|
2019-12-17 19:27:28 +00:00
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
|
|
|
const result = expected(function(payload) {
|
|
|
|
return Object.assign(
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
Datacenter: dc,
|
2021-09-15 18:50:11 +00:00
|
|
|
uid: `["default","default","${dc}","${id}"]`,
|
2019-12-17 19:27:28 +00:00
|
|
|
meta: {
|
2020-05-05 16:29:35 +00:00
|
|
|
cacheControl: undefined,
|
2019-12-17 19:27:28 +00:00
|
|
|
cursor: undefined,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
payload
|
|
|
|
);
|
|
|
|
});
|
|
|
|
assert.equal(actual.Datacenter, result.Datacenter);
|
|
|
|
assert.equal(actual.uid, result.uid);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|