-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3026 from toranb/master
added ember-testing integration test for issue #2997
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
var App, find, visit, originalAdapter; | ||
|
||
module("ember-testing Integration", { | ||
setup: function() { | ||
Ember.$('<div id="ember-testing-container"><div id="ember-testing"></div></div>').appendTo('body'); | ||
Ember.run(function() { | ||
App = Ember.Application.create({ | ||
rootElement: '#ember-testing' | ||
}); | ||
|
||
App.Router.map(function() { | ||
this.resource("people", { path: "/" }); | ||
}); | ||
|
||
App.PeopleRoute = Ember.Route.extend({ | ||
model: function() { | ||
return App.Person.find(); | ||
} | ||
}); | ||
|
||
App.PeopleView = Ember.View.extend({ | ||
defaultTemplate: Ember.Handlebars.compile("{{#each person in controller}}<div class=\"name\">{{person.firstName}}</div>{{/each}}") | ||
}); | ||
|
||
App.PeopleController = Ember.ArrayController.extend({}); | ||
|
||
App.Person = Ember.Object.extend({ | ||
firstName: '' | ||
}); | ||
|
||
App.Person.reopenClass({ | ||
find: function() { | ||
return Ember.A(); | ||
} | ||
}); | ||
|
||
App.ApplicationView = Ember.View.extend({ | ||
defaultTemplate: Ember.Handlebars.compile("{{outlet}}") | ||
}); | ||
|
||
App.setupForTesting(); | ||
}); | ||
|
||
Ember.run(function() { | ||
App.reset(); | ||
App.deferReadiness(); | ||
}); | ||
|
||
App.injectTestHelpers(); | ||
|
||
find = window.find; | ||
visit = window.visit; | ||
|
||
originalAdapter = Ember.Test.adapter; | ||
}, | ||
|
||
teardown: function() { | ||
App.removeTestHelpers(); | ||
Ember.$('#ember-testing-container, #ember-testing').remove(); | ||
Ember.run(App, App.destroy); | ||
App = null; | ||
Ember.Test.adapter = originalAdapter; | ||
} | ||
}); | ||
|
||
test("template is bound to array of 2 people", function() { | ||
App.Person.find = function() { | ||
var people = Ember.A(); | ||
var first = App.Person.create({firstName: "x"}); | ||
var last = App.Person.create({firstName: "y"}); | ||
Ember.run(people, people.pushObject, first); | ||
Ember.run(people, people.pushObject, last); | ||
return people; | ||
}; | ||
Ember.run(App, 'advanceReadiness'); | ||
visit("/").then(function() { | ||
var rows = find(".name").length; | ||
equal(rows, 2, "successfully stubbed the find method for the / route"); | ||
}); | ||
}); |