Files
threshold-ui/addons/api/tests/unit/models/session-recording-test.js
T

53 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-03-07 16:38:41 -05:00
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
2023-03-16 13:49:04 -04:00
import { TYPE_SESSION_RECORDING_SSH } from 'api/models/session-recording';
2023-03-07 16:38:41 -05:00
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
2023-03-16 13:49:04 -04:00
module('Unit | Model | session-recording', function (hooks) {
2023-03-07 16:38:41 -05:00
setupTest(hooks);
setupMirage(hooks);
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
2023-03-16 13:49:04 -04:00
let model = store.createRecord('session-recording', {});
2023-03-07 16:38:41 -05:00
assert.ok(model);
});
test('it has isUnknown property and returns the expected values', async function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
2023-03-16 13:49:04 -04:00
const modelA = store.createRecord('session-recording', {
type: TYPE_SESSION_RECORDING_SSH,
2023-03-07 16:38:41 -05:00
});
2023-03-16 13:49:04 -04:00
const modelB = store.createRecord('session-recording', {
2023-03-07 16:38:41 -05:00
type: 'no-such-type',
});
assert.false(modelA.isUnknown);
assert.true(modelB.isUnknown);
});
test('it has isSSH property and returns the expected values', async function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
2023-03-16 13:49:04 -04:00
const modelA = store.createRecord('session-recording', {
type: TYPE_SESSION_RECORDING_SSH,
2023-03-07 16:38:41 -05:00
});
2023-03-16 13:49:04 -04:00
const modelB = store.createRecord('session-recording', {
2023-03-07 16:38:41 -05:00
type: 'random',
});
assert.true(modelA.isSSH);
assert.false(modelB.isSSH);
});
test('it has connections as a relationship', async function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
2023-03-16 13:49:04 -04:00
const model = store.createRecord('session-recording', {
type: TYPE_SESSION_RECORDING_SSH,
connection_recordings: [store.createRecord('connection-recording')],
2023-03-07 16:38:41 -05:00
});
2023-03-16 13:49:04 -04:00
const connection_recordings = await model.connection_recordings;
assert.strictEqual(connection_recordings.length, 1);
2023-03-07 16:38:41 -05:00
});
});