vendredi 2 septembre 2016

ember unit test route - this is undefined

I try to write my first unit test for a route.

project/files

actions: {
  afterSave(savedFile){
    // ... some code
    let controller = this.controllerFor('project.files');
    // ...
  }
}

the test:

test('save file', function(assert) {
  let route = this.subject();
  console.log(route);
  let project;
  Ember.run(() => {
    project = route.get('store').createRecord('project', {
      id: '1',
      name: 'test'
    });

    let afterSave = route.get('actions.afterSave');
    afterSave(project);
  });  

  assert.ok(true);
})

The problem that I am getting TypeError: Cannot read property 'controllerFor' of undefined. It looks like this is undefined.




Aucun commentaire:

Enregistrer un commentaire