This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit test patient model mixin (#879)
* Add unit model test for patient - Add unit model test for patient * Add mixin unit test fro patient-name - Add mixin unit test fro patient-name * Add displayPatientName test for patient-name mixin - Add displayPatientName test for patient-name mixin
- Loading branch information
Showing
2 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import PatientName from 'hospitalrun/mixins/patient-name'; | ||
import { moduleFor, test } from 'ember-qunit'; | ||
import Ember from 'ember'; | ||
import DS from 'ember-data'; | ||
|
||
moduleFor('mixin:patient-name', 'Unit | Mixin | patient-name', { | ||
needs: [ | ||
'model:patient', | ||
'model:allergy', | ||
'model:payment', | ||
'model:price-profile' | ||
], | ||
subject(attrs) { | ||
let subject; | ||
Ember.run(() => { | ||
let Test = DS.Model.extend(PatientName); | ||
this.register('model:test', Test); | ||
subject = this.store().createRecord('test', attrs); | ||
}); | ||
|
||
return subject; | ||
}, | ||
store() { | ||
return this.container.lookup('service:store'); | ||
} | ||
}); | ||
|
||
test('getPatientDisplayId friendlyId', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
friendlyId: 'test', | ||
id: '123' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayId(patient), 'test'); | ||
}); | ||
|
||
test('getPatientDisplayId externalPatientId', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
externalPatientId: '1234', | ||
id: '4321' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayId(patient), '1234'); | ||
}); | ||
|
||
test('getPatientDisplayId id', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
id: '9876' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayId(patient), '9876'); | ||
}); | ||
|
||
test('getPatientDisplayName', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
firstName: 'First', | ||
lastName: 'Last', | ||
middleName: 'Middle' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayName(patient), 'First Middle Last'); | ||
}); | ||
|
||
test('getPatientDisplayName first', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
firstName: 'First' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayName(patient), 'First'); | ||
}); | ||
|
||
test('getPatientDisplayName first and last', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
firstName: 'First', | ||
lastName: 'Last' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayName(patient), 'First Last'); | ||
}); | ||
|
||
test('getPatientDisplayName last', function(assert) { | ||
let patient; | ||
Ember.run(() => { | ||
patient = this.store().createRecord('patient', { | ||
lastName: 'Last' | ||
}); | ||
}); | ||
|
||
assert.strictEqual(this.subject().getPatientDisplayName(patient), 'Last'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { moduleForModel, test } from 'ember-qunit'; | ||
import Ember from 'ember'; | ||
import tHelper from 'ember-i18n/helper'; | ||
import localeConfig from 'ember-i18n/config/en'; | ||
|
||
moduleForModel('patient', 'Unit | Model | patient', { | ||
needs: [ | ||
'ember-validations@validator:local/format', | ||
'ember-validations@validator:local/presence', | ||
'model:allergy', | ||
'model:payment', | ||
'model:price-profile', | ||
'service:i18n', | ||
'locale:en/translations', | ||
'locale:en/config', | ||
'util:i18n/missing-message', | ||
'util:i18n/compile-template', | ||
'config:environment' | ||
], | ||
beforeEach() { | ||
// set the locale and the config | ||
this.container.lookup('service:i18n').set('locale', 'en'); | ||
this.registry.register('locale:en/config', localeConfig); | ||
|
||
Ember.getOwner(this).inject('model', 'i18n', 'service:i18n'); | ||
|
||
// register t helper | ||
this.registry.register('helper:t', tHelper); | ||
} | ||
}); | ||
|
||
test('displayAddress', function(assert) { | ||
let patient = this.subject({ | ||
address: '123 Main St.', | ||
address2: 'Apt #2', | ||
address4: 'Test' | ||
}); | ||
|
||
assert.strictEqual(patient.get('displayAddress'), '123 Main St., Apt #2, Test'); | ||
}); |