source: imaps-frontend/node_modules/object-inspect/test/element.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.5 KB
Line 
1var inspect = require('../');
2var test = require('tape');
3
4test('element', function (t) {
5 t.plan(3);
6 var elem = {
7 nodeName: 'div',
8 attributes: [{ name: 'class', value: 'row' }],
9 getAttribute: function (key) { return key; },
10 childNodes: []
11 };
12 var obj = [1, elem, 3];
13 t.deepEqual(inspect(obj), '[ 1, <div class="row"></div>, 3 ]');
14 t.deepEqual(inspect(obj, { quoteStyle: 'single' }), "[ 1, <div class='row'></div>, 3 ]");
15 t.deepEqual(inspect(obj, { quoteStyle: 'double' }), '[ 1, <div class="row"></div>, 3 ]');
16});
17
18test('element no attr', function (t) {
19 t.plan(1);
20 var elem = {
21 nodeName: 'div',
22 getAttribute: function (key) { return key; },
23 childNodes: []
24 };
25 var obj = [1, elem, 3];
26 t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
27});
28
29test('element with contents', function (t) {
30 t.plan(1);
31 var elem = {
32 nodeName: 'div',
33 getAttribute: function (key) { return key; },
34 childNodes: [{ nodeName: 'b' }]
35 };
36 var obj = [1, elem, 3];
37 t.deepEqual(inspect(obj), '[ 1, <div>...</div>, 3 ]');
38});
39
40test('element instance', function (t) {
41 t.plan(1);
42 var h = global.HTMLElement;
43 global.HTMLElement = function (name, attr) {
44 this.nodeName = name;
45 this.attributes = attr;
46 };
47 global.HTMLElement.prototype.getAttribute = function () {};
48
49 var elem = new global.HTMLElement('div', []);
50 var obj = [1, elem, 3];
51 t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
52 global.HTMLElement = h;
53});
Note: See TracBrowser for help on using the repository browser.