1 | import XMLLite from 'xml-lite';
|
2 |
|
3 | const assert = chai.assert;
|
4 |
|
5 | describe('dom2js', () => {
|
6 | const testDiv = document.createElement('div');
|
7 | testDiv.innerHTML = `hello, world!
|
8 | <a href="https://github.com/leungwensen/xml-lite">
|
9 | maintaining xml in pure javascript (IN BOTH NODE.JS & BROWSERS)
|
10 | </a>`;
|
11 | testDiv.setAttribute('class', 'test-div');
|
12 | testDiv.setAttribute('data-hello', 'world');
|
13 | const elementObj = XMLLite.dom2js(testDiv);
|
14 |
|
15 | it('Element: type and tag', () => {
|
16 | assert.equal(
|
17 | elementObj.type,
|
18 | testDiv.ELEMENT_NODE,
|
19 | 'XMLLite.dom2js() not working: type is not right.'
|
20 | );
|
21 | assert.equal(
|
22 | elementObj.tag,
|
23 | 'DIV',
|
24 | 'XMLLite.dom2js() not working: tag is not right.'
|
25 | );
|
26 | });
|
27 |
|
28 | it('Element: attributes', () => {
|
29 | assert.deepEqual(
|
30 | elementObj.attributes,
|
31 | {
|
32 | class: 'test-div',
|
33 | 'data-hello': 'world',
|
34 | },
|
35 | 'XMLLite.dom2js() not working: something wrong with the attributes.'
|
36 | );
|
37 | });
|
38 | });
|