forked from x2js/x2js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests_funky.js
32 lines (26 loc) · 966 Bytes
/
tests_funky.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
(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('Funky tests');
QUnit.test('asArray() converts to array', function (assert) {
var x = new X2JS();
// It preserves existing arrays.
assert.propEqual(x.asArray([1, 2, 3]), [1, 2, 3]);
// And converts anything else.
assert.propEqual(x.asArray('stringvalue'), ['stringvalue']);
assert.propEqual(x.asArray({}), [{}]);
assert.propEqual(x.asArray(''), ['']);
// Except some things, which are turned into empty arrays just because.
assert.propEqual(x.asArray(null), []);
assert.propEqual(x.asArray(undefined), []);
});
});