Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@noelrappin
Last active December 16, 2015 23:59
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 noelrappin/5517935 to your computer and use it in GitHub Desktop.
Save noelrappin/5517935 to your computer and use it in GitHub Desktop.
Ember integration test
// This is my attempt at an ember controller integration test based on http://jsfiddle.net/ekidd/hCsws/
// It almost works..
// Here's what doesn't work: Template lookup
// In the view description, I have
// template: Ember.TEMPLATES.index
//
// it should be
// templateName: 'index'
//
// But that gives me an error:
//
// Error: assertion failed: You specified the templateName index for <Ember.View:ember344>, but it did not exist.
//
// And a deprecation warning:
// DEPRECATION: Using the defaultContainer is no longer supported. [defaultContainer#lookup]
//
// I think the error is related to: https://github.com/emberjs/ember.js/pull/2621
//
// But I don't know what I should be doing instead of using the default container? Is my application setup out of date (RC3)
//
describe("with an index controller", function() {
beforeEach(function() {
Ember.testing = true;
TimeTravel.reset();
Ember.run(function() {
this.trip = TimeTravel.Trip.createRecord({
name: "Mayflower",
startDate: "1620-09-06",
endDate: "1620-11-21"
});
controller = TimeTravel.IndexController.create({
container: TimeTravel.__container__,
content: [this.trip]
});
window.view = Ember.View.create({
controller: controller,
context: controller,
template: Ember.TEMPLATES.index
});
this.view.append();
});
});
afterEach(function() {
Ember.run(function() { window.view.remove() });
Ember.testing = false;
});
describe("basic stuff", function() {
it("displays trips", function() {
Ember.run(function() {
expect($(".trip").length).toEqual(1)
expect($(".trip .dates").text()).toEqual("Sep 6, 1620 - Nov 21, 1620")
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment