mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Start view_tests for Blaze
Want to test view.onRendered and view.onMaterialized while nailing down their API.
This commit is contained in:
@@ -39,7 +39,8 @@ Package.on_test(function (api) {
|
||||
api.use('tinytest');
|
||||
api.use('jquery'); // strong dependency, for testing jQuery backend
|
||||
api.use('blaze');
|
||||
api.use(['test-helpers', 'underscore'], 'client');
|
||||
api.use('test-helpers');
|
||||
api.use('underscore');
|
||||
|
||||
// ...
|
||||
api.add_files('view_tests.js');
|
||||
});
|
||||
|
||||
31
packages/blaze/view_tests.js
Normal file
31
packages/blaze/view_tests.js
Normal file
@@ -0,0 +1,31 @@
|
||||
if (Meteor.isClient) {
|
||||
|
||||
Tinytest.add("blaze - view - callbacks", function (test) {
|
||||
var R = Blaze._ReactiveVar('foo');
|
||||
|
||||
var buf = '';
|
||||
|
||||
var v = Blaze.View(function () {
|
||||
return R.get();
|
||||
});
|
||||
|
||||
v.onViewCreated(function () {
|
||||
buf += 'c';
|
||||
});
|
||||
v.onViewDestroyed(function () {
|
||||
buf += 'd';
|
||||
});
|
||||
|
||||
test.equal(buf, '');
|
||||
|
||||
var div = document.createElement("DIV");
|
||||
Blaze.insert(Blaze.render(v), div);
|
||||
test.equal(buf, 'c');
|
||||
test.equal(canonicalizeHtml(div.innerHTML), "foo");
|
||||
|
||||
Blaze.remove(v);
|
||||
test.equal(buf, 'cd');
|
||||
test.equal(canonicalizeHtml(div.innerHTML), "");
|
||||
});
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user