forked from brix/crypto-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib-base-test.js
92 lines (70 loc) · 3.06 KB
/
lib-base-test.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
91
92
YUI.add('lib-base-test', function (Y) {
var C = CryptoJS;
Y.Test.Runner.add(new Y.Test.Case({
name: 'Base',
setUp: function () {
this.data = {};
this.data.overrides = {
init: function (arg) {
this.initFired = true;
this.initArg = arg;
},
toString: function () {
}
};
this.data.mixins = {
mixinMethod: function () {
}
};
this.data.Obj = C.lib.Base.extend(this.data.overrides);
this.data.Obj.mixIn(this.data.mixins);
this.data.obj = this.data.Obj.create('argValue');
this.data.objClone = this.data.obj.clone();
},
testExtendInheritance: function () {
Y.Assert.areEqual(C.lib.Base.extend, this.data.Obj.extend);
Y.Assert.isFalse(this.data.Obj.hasOwnProperty('extend'));
},
testExtendSuper: function () {
Y.Assert.areEqual(C.lib.Base, this.data.Obj.$super);
},
testExtendOverrideInit: function () {
Y.Assert.areEqual(this.data.overrides.init, this.data.Obj.init);
Y.Assert.isTrue(this.data.Obj.hasOwnProperty('init'));
},
testExtendOverrideToString: function () {
Y.Assert.areEqual(this.data.overrides.toString, this.data.Obj.toString);
Y.Assert.isTrue(this.data.Obj.hasOwnProperty('toString'));
},
testCreateInheritanceFromBase: function () {
Y.Assert.areEqual(C.lib.Base.extend, this.data.obj.extend);
Y.Assert.isFalse(this.data.obj.hasOwnProperty('extend'));
},
testCreateSuper: function () {
Y.Assert.areEqual(this.data.Obj, this.data.obj.$super);
},
testCreateInit: function () {
Y.Assert.isTrue(this.data.obj.initFired);
Y.Assert.areEqual('argValue', this.data.obj.initArg);
},
testMixIn: function () {
Y.Assert.areEqual(this.data.mixins.mixinMethod, this.data.Obj.mixinMethod);
Y.Assert.isTrue(this.data.Obj.hasOwnProperty('mixinMethod'));
},
testCloneDistinct: function () {
Y.Assert.areNotEqual(this.data.obj, this.data.objClone);
},
testCloneCopy: function () {
Y.Assert.areEqual(this.data.obj.initArg, this.data.objClone.initArg);
},
testCloneIndependent: function () {
this.data.obj.initArg = 'newValue';
Y.Assert.areNotEqual(this.data.obj.initArg, this.data.objClone.initArg);
},
testCloneLeavesOriginalInitPrototypeUnchanged: function() {
Y.Assert.areEqual(this.data.obj, this.data.obj.init.prototype);
Y.Assert.areEqual(this.data.objClone, this.data.objClone.init.prototype);
Y.Assert.areNotEqual(this.data.obj.init.prototype, this.data.objClone.init.prototype);
}
}));
}, '$Rev$');