Created
March 29, 2016 04:12
-
-
Save he9qi/b6354a81a0672dc63294 to your computer and use it in GitHub Desktop.
Emberjs Model Relationship Test Helpers
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
import { test } from 'ember-qunit'; | |
import Ember from 'ember'; | |
export function testForHasMany(name, many) { | |
test('should have many ' + many, function(assert) { | |
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) { | |
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'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment