feat: Add 'deleteHostSet' method to a target

'deleteHostSet' wraps a host set id in an array and uses
'deleteHostSets' method
This commit is contained in:
Susmitha Girumala committed 2020-08-27 12:59:26 -04:00
1 parent 54008c8977
commit f97eebe1b8
3 files changed
+44 -1

No files matched your search

@@ -122,4 +122,37 @@ module('Unit | Model | target', function (hooks) {
const model = store.peekRecord('target', '123abc');
await model.deleteHostSets(['1', '3']);
});
test('it has a `deleteHostSet` method that deletes a single host set using `deleteHostSets` method', async function (assert) {
assert.expect(1);
this.server.post('/v1/scopes/o_1/targets/123abc:delete-host-sets', (schema, request) => {
const body = JSON.parse(request.requestBody);
assert.deepEqual(body, {
host_set_ids: ['3'],
version: 1
});
});
const store = this.owner.lookup('service:store');
store.push({
data: {
id: '123abc',
type: 'target',
attributes: {
name: 'Target',
description: 'Description',
host_sets: [
{ host_set_id: '1', host_catalog_id: '2' },
{ host_set_id: '3', host_catalog_id: '4' }
],
version: 1,
scope: {
scope_id: 'o_1',
type: 'scope'
}
}
}
});
const model = store.peekRecord('target', '123abc');
await model.deleteHostSet({id: '3'});
});
});