-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update task model tests & add relationship test helpers
- Loading branch information
Showing
2 changed files
with
48 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,25 @@ | ||
import { test } from 'ember-qunit'; | ||
import Ember from 'ember'; | ||
|
||
// source: https://gist.github.com/he9qi/b6354a81a0672dc63294 | ||
export function testForHasMany(name, many) { | ||
test('should have many ' + many, function(assert) { | ||
assert.expect(2); | ||
const Model = this.store().modelFor(name); | ||
const relationship = Ember.get(Model, 'relationshipsByName').get(many); | ||
|
||
assert.equal(relationship.key, many, 'has relationship with ' + many); | ||
assert.equal(relationship.kind, 'hasMany', 'kind of relationship is hasMany'); | ||
}); | ||
} | ||
|
||
export function testForBelongsTo(name, belongsTo) { | ||
test('should belong to ' + belongsTo, function(assert) { | ||
assert.expect(2); | ||
const Model = this.store().modelFor(name); | ||
const relationship = Ember.get(Model, 'relationshipsByName').get(belongsTo); | ||
|
||
assert.equal(relationship.key, belongsTo, 'has relationship with ' + belongsTo); | ||
assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); | ||
}); | ||
} |
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