Last active
January 3, 2016 06:59
-
-
Save ryanflorence/8426879 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var compile = Ember.Handlebars.compile; | |
module('Ember.Test Unit Tests', { | |
setup: function() { | |
Ember.Test.setupUnitTest(); | |
}, | |
teardown: function() { | |
Ember.Test.teardownUnitTest(); | |
} | |
}); | |
test('registerComponent and testComponent', function() { | |
expect(1); | |
registerComponent('test', Ember.Component); | |
testComponent('test').then(function(unit) { | |
ok(unit instanceof Ember.Component); | |
}); | |
}); | |
test('registerController and testController', function() { | |
expect(1); | |
registerController('test', Ember.Controller); | |
testController('test').then(function(unit) { | |
ok(unit instanceof Ember.Controller); | |
}); | |
}); | |
test('registerRoute and testRoute', function() { | |
expect(1); | |
registerRoute('test', Ember.Route); | |
testRoute('test').then(function(unit) { | |
ok(unit instanceof Ember.Route); | |
}); | |
}); | |
test('registerView and testView', function() { | |
expect(1); | |
registerView('test', Ember.View); | |
testView('test').then(function(unit) { | |
ok(unit instanceof Ember.View); | |
}); | |
}); | |
test('view: with template', function() { | |
expect(1); | |
var View = Ember.View.extend(); | |
// when using views that map to routes you need to specify the templateName | |
// either in your app or in your test with reopen | |
View.reopen({ templateName: 'test' }); | |
registerView('test', View); | |
registerTemplate('test', compile('test')); | |
testView('test').then(function(test) { | |
equal($('#qunit-fixture').text().trim(), 'test'); | |
}); | |
}); | |
test('component: with template', function() { | |
expect(1); | |
registerComponent('x-test', Ember.Component); | |
registerTemplate('components/x-test', compile('test')); | |
testComponent('x-test').then(function(component) { | |
equal($('#qunit-fixture').text().trim(), 'test'); | |
}); | |
}); | |
test('testSnippet', function() { | |
expect(2); | |
registerComponent('x-test', Ember.Component); | |
registerTemplate('components/x-test', compile('test')); | |
testSnippet("{{x-test id='☃'}}").then(function(view) { | |
ok(findView('☃') instanceof Ember.Component); | |
equal($('#qunit-fixture').text().trim(), 'test'); | |
}); | |
}); | |
test('helpers', function() { | |
expect(1); | |
Ember.Handlebars.registerHelper('echo', function(val) { | |
return val; | |
}); | |
testSnippet('{{echo "foo"}}').then(function(view) { | |
equal(view.$().text(), 'foo'); | |
}); | |
}); | |
//test('helper'); | |
//test('template'); | |
//test('testWithTemplate'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related PR's:
Ember.Application.buildContainer
.Ember.setupForTesting()
(which is called when you callApp.setupForTesting()
). Doesn't do too much yet, but it should be good to build onto.