Skip to content

Instantly share code, notes, and snippets.

@botandrose
Created May 18, 2015 21:36
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 botandrose/afe8cae68ec031362640 to your computer and use it in GitHub Desktop.
Save botandrose/afe8cae68ec031362640 to your computer and use it in GitHub Desktop.
Test to expose multiple app view -> controller binding regression in Ember 1.12
import "ember";
import EmberHandlebars from "ember-htmlbars/compat";
var compile = EmberHandlebars.compile;
var App1, App2, $fixture;
function setupExample() {
$fixture.append('<div id="app1"></div>');
$fixture.append('<div id="app2"></div>');
// setup templates
Ember.TEMPLATES.application = compile('{{outlet}}');
Ember.TEMPLATES.index = compile('{{view "select" content=model value=currentModel}}<span>{{currentModel}}</span>');
App1.IndexRoute = Ember.Route.extend({
model: function() {
return Ember.A(['red', 'yellow']);
}
});
App2.IndexRoute = Ember.Route.extend({
model: function() {
return Ember.A(['red', 'yellow']);
}
});
}
QUnit.module("Multiple Apps", {
setup: function() {
Ember.run(function() {
App1 = Ember.Application.create({
rootElement: '#app1'
});
App1.deferReadiness();
App1.Router.reopen({
location: 'none'
});
App2 = Ember.Application.create({
rootElement: '#app2'
});
App2.deferReadiness();
App2.Router.reopen({
location: 'none'
});
});
$fixture = Ember.$('#qunit-fixture');
setupExample();
},
teardown: function() {
Ember.run(function() {
App1.destroy();
App2.destroy();
});
App1 = App2 = null;
Ember.TEMPLATES = {};
}
});
QUnit.test("The example renders correctly", function() {
Ember.run(App1, 'advanceReadiness');
Ember.run(App2, 'advanceReadiness');
Ember.run(function() {
$fixture.find('#app1 select')[0].selectedIndex = 1;
$fixture.find('#app1 select').trigger('change');
$fixture.find('#app2 select')[0].selectedIndex = 1;
$fixture.find('#app2 select').trigger('change');
});
equal($fixture.find('#app1 span').text(), 'yellow');
equal($fixture.find('#app2 span').text(), 'yellow');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment