ember.js - How to access needs elements in ember-cli unit test -


in route test need access service, retrieve model. have referenced service via needs, inside test don't see way of accessing service.

import {   modulefor,   test } 'ember-qunit';   modulefor('route:application', {   needs: ['route:application','controller:application','service:dialog'] });  test('can open , remove dialog dialog', function(assert) {     var route = this.subject();     route.setproperties({       controller: { // don't part ..          dialogs:null       }     });      // need access service here model     // :     //var service = this.get('service:dialog');     var modalmodel = service.getmodal('business/contract-edit');      ...   }); 

how can access service inside test?

(btw: i'm using ember v2.0.0)

found solution. key when using needs, resources can accessed via container inside test:

modulefor('route:application', {   // specify other units required test.   needs: ['route:application','controller:application','service:dialog'] });  test('can open , remove dialog dialog', function(assert) {   var route = this.subject();   var controller = this.container.lookup('controller:application');   var service = this.container.lookup('service:dialog');  ... }) 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -