feat: Add isCancelable attribute to session model

Closes: gs
This commit is contained in:
Susmitha Girumala committed 2020-10-05 16:09:34 -04:00
1 parent 4b5f02da2a
commit 523c2f7a5a
2 files changed
+28 -1

No files matched your search

+11
View File
@@ -1,7 +1,18 @@
import GeneratedSessionModel from '../generated/models/session';
import { computed } from '@ember/object';
export default class SessionModel extends GeneratedSessionModel {
// =attributes
/**
* @type {boolean}
*/
@computed('status')
get isCancelable() {
return this.status?.match(/(active)|(pending)/i);
}
// =methods
/**
+17 -1
View File
@@ -4,10 +4,26 @@ import { setupTest } from 'ember-qunit';
module('Unit | Model | session', function(hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {});
assert.ok(model);
assert.notOk(model.isCancelable);
});
test('it allows cancellation of an active session', function(assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
status: 'active'
});
assert.ok(model.isCancelable);
});
test('it allows cancellation of a pending session', function(assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('session', {
status: 'pending'
});
assert.ok(model.isCancelable);
});
});