Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stubbing Relationships in Model Unit Tests
UPDATE: Actually, doing this with `reopen` is apparently deprecated. Back to creating actual objects for relationships -_-
don't do this below stuff

Stubbing relationships in model unit tests

// model
export default DS.Model.extend({
  addonService: DS.belongsTo('addon-service')
});
// unit test setup that does NOT work
beforeEach(function () {
  addon = this.store().createRecord('addon', {
    addonService: Ember.Object.create({
      name: 'addon-service-name'
    })
  });
});
// unit test setup that works
beforeEach(function () {
  addon = this.store().createRecord('addon');
  addon.reopen({
    addonService: Ember.Object.create({
      name: 'addon-service-name'
    })
  });
});
@caseywatts

This comment has been minimized.

Copy link
Owner Author

@caseywatts caseywatts commented Jan 18, 2017

Actually, doing this with reopen is apparently deprecated.
Back to creating actual objects for relationships -_-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment