corrade-nucleus-nucleons – Blame information for rev 37
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
37 | office | 1 | (function (root, factory) { |
2 | 'use strict'; |
||
3 | |||
4 | if (typeof module === 'object' && module.exports) { |
||
5 | // Node. Does not work with strict CommonJS, but only CommonJS-like
|
||
6 | // environments that support module.exports, like Node.
|
||
7 | factory(require('./x2js'), require('qunit-cli')); |
||
8 | } else { |
||
9 | // Browser globals (root is window)
|
||
10 | factory(root.X2JS, root.QUnit); |
||
11 | } |
||
12 | })(this, function (X2JS, QUnit) { |
||
13 | 'use strict'; |
||
14 | |||
15 | QUnit.module('Smoke tests'); |
||
16 | |||
17 | QUnit.test('X->JS single element', function (assert) { |
||
18 | var xml = '<document><element>text</element></document>'; |
||
19 | var x = new X2JS(); |
||
20 | |||
21 | var js = x.xml2js(xml); |
||
22 | |||
23 | assert.ok(js.document); |
||
24 | assert.ok(js.document.element); |
||
25 | assert.strictEqual(js.document.element, 'text'); |
||
26 | }); |
||
27 | |||
28 | QUnit.test('X->JS two elements', function (assert) { |
||
29 | var xml = '<document><element1>text</element1><element2>text2</element2></document>'; |
||
30 | var x = new X2JS(); |
||
31 | |||
32 | var js = x.xml2js(xml); |
||
33 | |||
34 | assert.ok(js.document); |
||
35 | assert.ok(js.document.element1); |
||
36 | assert.strictEqual(js.document.element1, 'text'); |
||
37 | assert.ok(js.document.element2); |
||
38 | assert.strictEqual(js.document.element2, 'text2'); |
||
39 | }); |
||
40 | }); |