Skip to content

Instantly share code, notes, and snippets.

@balinterdi
Created September 15, 2014 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balinterdi/00ad17faf5c9e9704f3c to your computer and use it in GitHub Desktop.
Save balinterdi/00ad17faf5c9e9704f3c to your computer and use it in GitHub Desktop.
controller_test.js
var stuntAnalytics;
moduleFor('controller:song', 'Unit - Song controller', {
needs: [
'controller:song'
],
setup: function() {
stuntAnalytics = MockAnalytics.create(); // create with a mock library, like sinon;
this.container.register('service:analytics', stuntAnalytics);
this.container.inject('controller', 'analytics', 'service:analytics');
}
});
test('Analytics', function() {
var controller = this.container.create('controller:post');
controller.sendAnalytics({ type: "click", value: '2', currency: 'USD' });
test(..., "The analytics service is called with the correct parameters"); // verify the mock
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment