Skip to content

Commit

Permalink
htmlelement instance coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Aug 5, 2014
1 parent 8d753fb commit 397ffe1
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions test/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ test('element', function (t) {
var elem = {
nodeName: 'div',
attributes: [ { name: 'class', value: 'row' } ],
getAttribute: function (key) {
return elem.attributes[key];
},
getAttribute: function (key) {},
childNodes: []
};
var obj = [ 1, elem, 3 ];
Expand All @@ -19,9 +17,7 @@ test('element no attr', function (t) {
t.plan(1);
var elem = {
nodeName: 'div',
getAttribute: function (key) {
return elem.attributes[key];
},
getAttribute: function (key) {},
childNodes: []
};
var obj = [ 1, elem, 3 ];
Expand All @@ -32,11 +28,24 @@ test('element with contents', function (t) {
t.plan(1);
var elem = {
nodeName: 'div',
getAttribute: function (key) {
return elem.attributes[key];
},
getAttribute: function (key) {},
childNodes: [ { nodeName: 'b' } ]
};
var obj = [ 1, elem, 3 ];
t.deepEqual(inspect(obj), '[ 1, <div>...</div>, 3 ]');
});

test('element instance', function (t) {
t.plan(1);
var h = global.HTMLElement;
global.HTMLElement = function (name, attr) {
this.nodeName = name;
this.attributes = attr;
};
global.HTMLElement.prototype.getAttribute = function () {};

var elem = new(global.HTMLElement)('div', []);
var obj = [ 1, elem, 3 ];
t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
global.HTMLElement = h;
});

0 comments on commit 397ffe1

Please sign in to comment.