2018-04-25 10:04:10 +00:00
|
|
|
window.onload = function() {
|
|
|
|
|
2021-10-14 14:35:12 +00:00
|
|
|
QUnit.test("model bindings and rebinding", assert => {
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
var callback_count1 = 0
|
|
|
|
var callbacks = App.Template._callbacks
|
|
|
|
Object.keys(callbacks).forEach(function(key) {
|
|
|
|
callback_count1 = callback_count1 + callbacks[key].length
|
|
|
|
});
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.equal(callback_count1, 2)
|
2018-04-25 10:04:10 +00:00
|
|
|
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
App.Template.clearInMemory()
|
|
|
|
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
var callback_count2 = 0
|
|
|
|
callbacks = App.Template._callbacks
|
|
|
|
Object.keys(callbacks).forEach(function(key) {
|
|
|
|
callback_count2 = callback_count2 + callbacks[key].length
|
|
|
|
});
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.equal(callback_count2, callback_count1)
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
var render = function() {}
|
|
|
|
var subscribe_id = App.Template.subscribe(render, {initFetch: true})
|
|
|
|
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
|
|
|
|
assert.ok(!_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
var callback_count3 = 0
|
|
|
|
callbacks = App.Template._callbacks
|
|
|
|
Object.keys(callbacks).forEach(function(key) {
|
|
|
|
callback_count3 = callback_count3 + callbacks[key].length
|
|
|
|
});
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.equal(callback_count3, 6)
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
App.Template.clearInMemory()
|
|
|
|
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
|
|
|
|
assert.ok(_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
var callback_count4 = 0
|
|
|
|
callbacks = App.Template._callbacks
|
|
|
|
Object.keys(callbacks).forEach(function(key) {
|
|
|
|
callback_count4 = callback_count4 + callbacks[key].length
|
|
|
|
});
|
2021-10-14 14:35:12 +00:00
|
|
|
assert.equal(callback_count4, callback_count3)
|
2018-04-25 10:04:10 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|