2019-12-17 19:27:28 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
2020-02-18 16:43:52 +00:00
|
|
|
import getNspaceRunner from 'consul-ui/tests/helpers/get-nspace-runner';
|
2019-12-17 19:27:28 +00:00
|
|
|
|
2020-02-18 16:43:52 +00:00
|
|
|
const nspaceRunner = getNspaceRunner('discovery-chain');
|
2019-12-17 19:27:28 +00:00
|
|
|
module('Integration | Adapter | discovery-chain', function(hooks) {
|
|
|
|
setupTest(hooks);
|
|
|
|
const dc = 'dc-1';
|
|
|
|
const id = 'slug';
|
|
|
|
test('requestForQueryRecord returns the correct url/method', function(assert) {
|
|
|
|
const adapter = this.owner.lookup('adapter:discovery-chain');
|
|
|
|
const client = this.owner.lookup('service:client/http');
|
|
|
|
const expected = `GET /v1/discovery-chain/${id}?dc=${dc}`;
|
|
|
|
const actual = adapter.requestForQueryRecord(client.url, {
|
|
|
|
dc: dc,
|
|
|
|
id: id,
|
|
|
|
});
|
|
|
|
assert.equal(actual, expected);
|
|
|
|
});
|
|
|
|
test("requestForQueryRecord throws if you don't specify an id", function(assert) {
|
|
|
|
const adapter = this.owner.lookup('adapter:discovery-chain');
|
|
|
|
const client = this.owner.lookup('service:client/http');
|
|
|
|
assert.throws(function() {
|
|
|
|
adapter.requestForQueryRecord(client.url, {
|
|
|
|
dc: dc,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-02-18 16:43:52 +00:00
|
|
|
test('requestForQueryRecord returns the correct body', function(assert) {
|
|
|
|
return nspaceRunner(
|
|
|
|
(adapter, serializer, client) => {
|
|
|
|
return adapter.requestForQueryRecord(client.body, {
|
|
|
|
id: id,
|
|
|
|
dc: dc,
|
|
|
|
ns: 'team-1',
|
|
|
|
index: 1,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
index: 1,
|
|
|
|
ns: 'team-1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
index: 1,
|
|
|
|
},
|
|
|
|
this,
|
|
|
|
assert
|
|
|
|
);
|
|
|
|
});
|
2019-12-17 19:27:28 +00:00
|
|
|
});
|