forked from x2js/x2js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests_smoke.js
40 lines (32 loc) · 1.13 KB
/
tests_smoke.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function (root, factory) {
'use strict';
if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but only CommonJS-like
// environments that support module.exports, like Node.
factory(require('./x2js'), require('qunit-cli'));
} else {
// Browser globals (root is window)
factory(root.X2JS, root.QUnit);
}
})(this, function (X2JS, QUnit) {
'use strict';
QUnit.module('Smoke tests');
QUnit.test('X->JS single element', function (assert) {
var xml = '<document><element>text</element></document>';
var x = new X2JS();
var js = x.xml2js(xml);
assert.ok(js.document);
assert.ok(js.document.element);
assert.strictEqual(js.document.element, 'text');
});
QUnit.test('X->JS two elements', function (assert) {
var xml = '<document><element1>text</element1><element2>text2</element2></document>';
var x = new X2JS();
var js = x.xml2js(xml);
assert.ok(js.document);
assert.ok(js.document.element1);
assert.strictEqual(js.document.element1, 'text');
assert.ok(js.document.element2);
assert.strictEqual(js.document.element2, 'text2');
});
});