4
votes

I've successfully refactored my site to handle the new Ember 1.0 and Ember-data 1.0 beta. I'm trying to convert my unit & integration tests, which runs with karma-runner.

I get stuck in a simple test that verifies that data is stored correctly in the models. Here is a sample test that worked on the previous version of ember-data (0.13?) and ember.js RC6.

While I know that within a controller or router function, this might work to get model data: this.store.find('me'); But would that statement work in a test script? I haven't been able to get it to work. Is there a way to access model data when testing?

Bryan

1

1 Answers

6
votes

For tests you can always lookup the store in the application container by doing:

App.__container__.lookup('store:main');

So, something like this should work:

test('user is authenticated', function() {
  var store = App.__container__.lookup('store:main');
  var me;
  me = store.find('me');
  me.set('IsAuthenticated', true);
  ok(me.get('IsAuthenticated'), "user should be authenticated.");
});

Hope it helps.