I am trying to do an integration test for an Ember component that requires a model as input. I have mock data, but I cannot pass it into the component directly because the model includes computed properties and other customizations that EmberData normally handles under the hood. However, I cannot figure out how to inject the store into the test to convert my mock data into an Ember model. I've tried a few different approaches, none of which work:
Ember.inject.service('store');
this.get('store')
var store = this.container.lookup('service:store');
Ember.getOwner(this).lookup("service:store");
None of these actually work. I'm using Ember v2.9.1. The code for my integration test is below.
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('host-pod', 'Integration | Component | host-pod', {
integration: true
});
test('it renders', function(assert) {
... code to get store ...
this.set('mockModel', store.normalize('model', mockModel));
this.render(hbs``);
assert.equal(this.$().length, 1);
});
var mockModel = { ... }
Aucun commentaire:
Enregistrer un commentaire