vendredi 22 mai 2015

Testing extended core ember objects in ember-cli

I have created an ember-cli application where I needed to extend the default store from ember-data. To do this I have created a file at app/store.js and simply extended the store as such:

export default DS.Store.extend({
  findOrCreateRecord: function(type, properties, preload) {
    ...
  }
});

This works great, but when I come to testing an initialiser that makes use of this new method I get the following error:

'undefined' is not a function (evaluating 'store.findOrCreateRecord()') Is there anything I need to do for my tests to play nicely here? The file that I am testing is the initialiser below:

export function initialize(container, app) {
  var store = container.lookup('store:main');
  app.deferReadiness();

  store.findOrCreateRecord('order', basketToken).then(function(basket) {
    container.register('basket:main', basket, { instantiate: false });
    app.inject('controller:basket', 'model', 'basket:main');
    app.advanceReadiness();
  });
}

As for the test file itself, it is the default one that ember-cli generates with NO modifications at all




Aucun commentaire:

Enregistrer un commentaire