Skip to content

Commit

Permalink
Test for defining a DOM element
Browse files Browse the repository at this point in the history
Breaking test for #145
  • Loading branch information
matthewp committed Feb 3, 2017
1 parent 61f1c05 commit c93641f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions define-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var define = require("can-define");
var stache = require("can-stache");
var CanList = require("can-list");
var canBatch = require("can-event/batch/batch");
var domDispatch = require("can-util/dom/dispatch/dispatch");
var isArray = require("can-util/js/is-array/is-array");
var each = require("can-util/js/each/each");
var types = require("can-types");
Expand Down Expand Up @@ -1504,3 +1505,23 @@ QUnit.test('setter with default value causes an infinite loop (#142)', function(
var a = new A();
QUnit.equal(a.val, 'hello', 'creating an instance should not cause an inifinte loop');
});

QUnit.test('Works with DOM elements', function(){
var el = document.createElement('div');
define(el, { foo: 'string' });

var events = 0;
el.addEventListener('foo', function(){
events++;
});

el.addEventListener('some-event', function(){
events++;
});

el.foo = 'bar';
QUnit.equal(events, 1, 'An event occurred');

domDispatch.call(el, "some-event");
QUnit.equal(events, 2, 'Another event');
});

0 comments on commit c93641f

Please sign in to comment.