Skip to content

Commit

Permalink
Merge pull request #111 from canjs/fix-tag-duplication
Browse files Browse the repository at this point in the history
using unique tag names to prevent conflicts with other tests
  • Loading branch information
phillipskevin authored Jan 3, 2019
2 parents 151ffb9 + b877ab9 commit 0450c6b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions test/callbacks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ function afterMutation(cb) {
domMutateNode.appendChild.call(doc.body, div);
}

QUnit.module('can-view-callbacks', {
beforeEach: function() {
// reset tags to prevent conflicts between tests
callbacks._tags = {};
}
});
QUnit.module('can-view-callbacks');

QUnit.test('Initialized the plugin', function(){
var handler = function(){
Expand Down Expand Up @@ -570,17 +565,17 @@ QUnit.test("MutationObserver mounts each element once in browsers that do not su
var fixture = doc.getElementById('qunit-fixture');
var innerElCounter = 0, outerElCounter = 0;

callbacks.tag("inner-el", function(el) {});
callbacks.tag("outer-el", function(el) {
var inner = doc.createElement("inner-el");
callbacks.tag("mount-once-inner", function(el) {});
callbacks.tag("mount-once-outer", function(el) {
var inner = doc.createElement("mount-once-inner");
el.appendChild(inner);
});

var origTagHandler = callbacks.tagHandler;
callbacks.tagHandler = function(el, tagName) {
if (tagName === "inner-el") {
if (tagName === "mount-once-inner") {
innerElCounter++;
} else if (tagName === "outer-el") {
} else if (tagName === "mount-once-outer") {
outerElCounter++;
}
origTagHandler.apply(this, arguments);
Expand All @@ -597,6 +592,6 @@ QUnit.test("MutationObserver mounts each element once in browsers that do not su
QUnit.start();
});

var outer = doc.createElement("outer-el");
var outer = doc.createElement("mount-once-outer");
fixture.appendChild(outer);
});

0 comments on commit 0450c6b

Please sign in to comment.