mercredi 20 janvier 2016

How do you inject the session for a unit test in ember-simple-auth?

I am unable to setup my unit test for an application route in my ember application.

Very simple route:

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin, {});

Very simple test:

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


import { authenticateSession } from '../../helpers/ember-simple-auth';

moduleFor('route:application', {
    beforeEach: function(){
        this.subject().set('session', authenticateSession);
    },
});

test('it exists', function(assert) {
  var route = this.subject();
  assert.ok(route);
});

I have tried several things, but they all throw the error:

Promise rejected before it exists: 'undefined' is not an object (evaluating '_this.get('session').on')

Which seems to indicate that the session is undefined in the mixin, anyone have unit tests working? I could convert to a integration test, but would prefer to keep it as a unit level if possible.




Aucun commentaire:

Enregistrer un commentaire