This repository was archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathutility.js
90 lines (83 loc) · 2.52 KB
/
utility.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var $ = require("../lib/abaaso.js");
exports["alias"] = {
setUp: function (done) {
this.origin = {test: function () { return true; }};
done();
},
test: function (test) {
var dest = {};
test.expect(3);
test.equal($.alias(dest, this.origin), dest, "Should be `dest` Object");
test.equal(typeof dest.test, "function", "Should be `function`");
test.equal(this.origin.test(), dest.test(), "Should match");
test.done();
}
};
exports["clone"] = {
setUp: function (done) {
this.array = [true, false, true];
done();
},
test: function (test) {
var dest;
test.expect(3);
test.equal((dest = $.clone(this.array)).length, this.array.length, "Should be an identical Array");
test.equal(dest.push(false), 4, "Should be `4`");
test.equal(this.array.length, 3, "Should be `3`");
test.done();
}
};
exports["coerce"] = {
setUp: function (done) {
this.number = "1234";
this.boolean = "true";
this.json = "{\"test\": true}";
this.undefined = "undefined";
this.null = "null";
done();
},
test: function (test) {
test.expect(5);
test.equal($.coerce(this.number), 1234, "Should be `1234`");
test.equal($.coerce(this.boolean), true, "Should be `true`");
test.equal($.coerce(this.json) instanceof Object, true, "Should be an Object");
test.equal($.coerce(this.undefined), undefined, "Should be `undefined`");
test.equal($.coerce(this.null), null, "Should be `null`");
test.done();
}
};
exports["define"] = {
setUp: function (done) {
this.obj = {};
done();
},
object: function (test) {
test.expect(6);
test.equal($.define("a.b.c.1", true, this.obj), this.obj, "Should be `this.obj`");
test.equal(typeof this.obj.a, "object", "Should be `object`");
test.equal(typeof this.obj.a.b, "object", "Should be `object`");
test.equal(typeof this.obj.a.b.c, "object", "Should be `object`");
test.equal(this.obj.a.b.c instanceof Object, true, "Should be `true`");
test.equal(this.obj.a.b.c["1"], true, "Should be `true`");
test.done();
},
array: function (test) {
test.expect(3);
test.equal($.define("a.b.c.2", false, this.obj), this.obj, "Should be `this.obj`");
test.equal(typeof this.obj.a.b.c, "object", "Should be `object`");
test.equal(this.obj.a.b.c instanceof Array, true, "Should be `true`");
test.done();
}
};
exports["extend"] = {
setUp: function (done) {
this.obj = {method: function () { void 0; }};
this.ext = {};
done();
},
test: function (test) {
test.expect(1);
test.equal(this.ext = $.extend(this.obj), this.ext, "Should be `this.ext`");
test.done();
}
};