Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Add mixin unit tests for location-name #884

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions tests/unit/mixins/location-name-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import LocationName from 'hospitalrun/mixins/location-name';
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
import DS from 'ember-data';

moduleFor('mixin:location-name', 'Unit | Mixin | location-name', {
subject(attrs) {
let subject;
Ember.run(() => {
let Test = DS.Model.extend(LocationName);
this.register('model:test', Test);
subject = this.store().createRecord('test', attrs);
});

return subject;
},
store() {
return this.container.lookup('service:store');
}
});

test('getDisplayLocationName', function(assert) {
let locationName = this.subject();

assert.strictEqual(
locationName.getDisplayLocationName('Location', 'Aisle'),
'Location : Aisle',
'Should include both'
);
assert.strictEqual(
locationName.getDisplayLocationName('Location'),
'Location',
'Should only include location'
);
assert.strictEqual(
locationName.getDisplayLocationName('', 'Aisle'),
'Aisle',
'Should only include aisle location'
);
assert.strictEqual(
locationName.getDisplayLocationName('', ''),
'No Location',
'Should return default "No Location" message'
);
});

test('locationName', function(assert) {
let locationName = this.subject({
location: 'Location',
aisleLocation: 'Aisle'
});

assert.strictEqual(locationName.get('locationName'), 'Location : Aisle');
});