Skip to content

Instantly share code, notes, and snippets.

@walter
Created March 10, 2015 20:22
Show Gist options
  • Save walter/dcfbfc0b853a2a7f563b to your computer and use it in GitHub Desktop.
Save walter/dcfbfc0b853a2a7f563b to your computer and use it in GitHub Desktop.
test('renderTemplate sets application.duringQuestionSteps to true',
function(assert) {
var route = this.subject(),
applicationController = route.controllerFor('application'),
didRender;
// http://discuss.emberjs.com/t/test-isolation-aka-how-wrong-am-i-doing-it/7162/2
route.render = function mockRender(route) {
didRender = true;
};
route.send('renderTemplate');
assert.equal(applicationController.get('duringQuestionSteps'), true);
assert.ok(didRender, 'expected to render');
});
@walter
Copy link
Author

walter commented Mar 10, 2015

Here's what it is testing:

import Ember from 'ember';

export default Ember.Route.extend({
  renderTemplate: function() {
    this.controllerFor('application').set('duringQuestionSteps', true);

    this.render({ into: 'application', outlet: 'question-steps' });
  },
  actions: {
    personSelect: function() {
      this.transitionTo('questions.new');

      return false;
    }
  }
});

@walter
Copy link
Author

walter commented Mar 10, 2015

Figured it out thanks to http://weichienhung.github.io/blog/2014/03/08/unit-testing-in-emberjs/.

Rather than do this:

route.send('renderTemplate');

I needed to do this:

route.renderTemplate();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment