jeudi 18 juin 2015

How to access needs elements in ember-cli unit test

In a route test I need to access a service, to retrieve a model. I have referenced the service via needs, but inside the test I don't see a way of accessing the service.

import {
  moduleFor,
  test
} from 'ember-qunit';


moduleFor('route:application', {
  needs: ['route:application','controller:application','service:dialog']
});

test('can open and remove a dialog dialog', function(assert) {
    var route = this.subject();
    route.setProperties({
      controller: { // don't like this part as well .. 
        dialogs:null
      }
    });

    // need to access the service here to get a model
    // something like :
    //var service = this.get('service:dialog');
    var modalModel = service.getModal('business/contract-edit');

    ...


});

How can I access the service inside the test?

(BTW: I'm using ember v2.0.0)

Aucun commentaire:

Enregistrer un commentaire