Files
threshold-ui/ui/desktop/tests/unit/abilities/target-test.js
T
Lisbet Alvarez 3740bb079a Icu-11111 don't display empty modal when a target has no target address and no host sources (#1909)
* fix: 🐛 disable connect buttons & add message

✅ Closes: ICU-11111

* test: 💍 add test cases

* fix: 🐛 buttons on list view & add getter to target model

* refactor: 💡 use can ability instead and remove Promise.all

* test: 💍 fix expect number
2023-09-22 18:58:15 -04:00

31 lines
982 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | target', function (hooks) {
setupTest(hooks);
test('it reflects when a target can initiate connection or not', function (assert) {
assert.expect(5);
const service = this.owner.lookup('service:can');
const model = {
address: '',
};
assert.false(service.can('initiateConnection target', model));
model.host_sources = [];
assert.false(service.can('initiateConnection target', model));
model.address = 'localhost';
assert.true(service.can('initiateConnection target', model));
model.address = '';
model.host_sources = ['host_123'];
assert.true(service.can('initiateConnection target', model));
model.address = 'localhost';
model.host_sources = ['host_123'];
assert.true(service.can('initiateConnection target', model));
});
});