Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use afterMutation helper for test #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"can-view-target": "^3.1.0"
},
"devDependencies": {
"can-globals": "^0.2.6",
"can-list": "^3.2.0",
"can-map": "^3.3.1",
"detect-cyclic-packages": "^1.1.0",
Expand Down
28 changes: 14 additions & 14 deletions test/live-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var nodeLists = require('can-view-nodelist');
var canBatch = require('can-event/batch/batch');
var Observation = require("can-observation");
var domEvents = require('can-util/dom/events/events');
var globals = require('can-globals');

var QUnit = require('steal-qunit');

Expand Down Expand Up @@ -223,25 +224,25 @@ test('list with a compute that returns a list', function () {
equal(spans.length, 3, 'there are 3 spans');
});

test('text binding is memory safe (#666)', function () {
nodeLists.nodeMap.clear();
test('text binding is memory safe (#666)', function (assert) {
var done = assert.async();
var div = document.createElement('div');
var span = document.createElement('span');
var text = compute(function () {
return 'foo';
});

var div = document.createElement('div'),
span = document.createElement('span'),
text = compute(function () {
return 'foo';
});
nodeLists.nodeMap.clear();
div.appendChild(span);

domMutate.appendChild.call(this.fixture, div);

live.text(span, text, div);
domMutate.removeChild.call(this.fixture, div);
stop();
setTimeout(function () {
ok(!nodeLists.nodeMap.size, 'nothing in nodeMap');
start();
}, 100);

domEvents.addEventListener.call(div, 'removed', function () {
assert.ok(!nodeLists.nodeMap.size, 'nothing in nodeMap');
done();
});
});

test('html live binding handles getting a function from a compute',5, function(){
Expand Down Expand Up @@ -638,4 +639,3 @@ QUnit.test("events are torn down from correct list on change", function() {
ok(!list.__bindEvents.add || list.__bindEvents.add.length === 0, "Add handler has been removed from list");
ok(filteredList.__bindEvents.add && filteredList.__bindEvents.add.length > 0, "Add handler has been added to filteredList");
});