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

62 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-09-18 10:16:40 -04:00
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
2021-03-04 15:47:38 -05:00
module('Unit | Model | session', function (hooks) {
2020-09-18 10:16:40 -04:00
setupTest(hooks);
2021-03-04 15:47:38 -05:00
test('it exists', function (assert) {
2020-09-18 10:16:40 -04:00
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {});
assert.ok(model);
assert.notOk(model.isCancelable);
});
2021-03-04 15:47:38 -05:00
test('it allows cancellation of an active session', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
2021-03-04 15:47:38 -05:00
status: 'active',
});
assert.ok(model.isCancelable);
});
2021-03-04 15:47:38 -05:00
test('it allows cancellation of a pending session', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
2021-03-04 15:47:38 -05:00
status: 'pending',
});
assert.ok(model.isCancelable);
2020-09-18 10:16:40 -04:00
});
2021-02-05 16:57:06 -05:00
test('it computes isActive', function (assert) {
assert.expect(2);
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
2021-03-04 15:47:38 -05:00
status: 'pending',
2021-02-05 16:57:06 -05:00
});
assert.notOk(model.isActive);
model.status = 'active';
assert.ok(model.isActive);
});
test('it computes isPending', function (assert) {
assert.expect(2);
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
2021-03-04 15:47:38 -05:00
status: 'active',
2021-02-05 16:57:06 -05:00
});
assert.notOk(model.isPending);
model.status = 'pending';
assert.ok(model.isPending);
});
test('it computes a proxy attribute', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session');
assert.equal(model.proxy, null);
model.setProperties({
proxy_address: 'localhost',
2021-03-04 15:47:38 -05:00
proxy_port: '12345',
});
assert.equal(model.proxy, 'localhost:12345');
});
2020-09-18 10:16:40 -04:00
});