-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAvert.test.js
238 lines (186 loc) · 12.1 KB
/
Avert.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
var WasDisplayCalled=false;
var parameterPassedToDisplay={};
var setUpSampleDisplayPlugin=function(){
WasDisplayCalled=false;
parameterPassedToDisplay={};
(function (a) {
a.SD(function (output_data) {
WasDisplayCalled=true;
parameterPassedToDisplay=output_data;
});
})(Aver);
};
var nameOfSampleTestPlug="testPlug";//critical to test setup!!!!!
var WasTestPlugCalled=false;
var passedActualValue={};
var passedExpectedValue={};
var setUpSampleTestPlug=function(){
passedActualValue={};
passedExpectedValue={};
WasTestPlugCalled=false;
(function (a) {
var IsEqualTo = {
name: nameOfSampleTestPlug,
method: function (actualValue, expectedValue) {
WasTestPlugCalled=true;
passedActualValue=actualValue;
passedExpectedValue=expectedValue;
return true;
}
};
a.PI(IsEqualTo);
})(Aver);
};
test( "That public method for Setting up Display Avert.SD is exposed", function() {
ok( typeof(Aver.SD) == "function", "Public 'Aver.SD' must be exposed to set up display!" );
});
test( "That public method for Setting up Test Plugs Avert.PI is exposed", function() {
ok( typeof(Aver.PI) == "function", "Public 'Aver.PI' must be exposed to set up Test Plugs!" );
});
test( "That public method for starting test specification Avert.WhenTesting is exposed", function() {
ok( typeof(Aver.WhenTesting) == "function", "Public 'Aver.WhenTesting' must be exposed to enable user start test specification!" );
});
test( "making sure local variable Aver.WhenTesting.ToMakeSure is exposed", function() {
ok( typeof(Aver.WhenTesting().ToMakeSure) == "function", "local 'Aver.WhenTesting.ToMakeSure' must be accesible!" );
});
test( "making sure internal testplug Aver.WhenTesting.ToMakeSure.Is is exposed", function() {
ok( typeof(Aver.WhenTesting().ToMakeSure().Is) == "function", "internal test plug 'Aver.WhenTesting.ToMakeSure.Is' must be accesible!" );
});
test( "That public short method for test specification Avert.T is exposed", function() {
ok( typeof(Aver.T) == "function", "short method for test specification Avert.T must be exposed!" );
});
test( "sample test 'true' using internal test plug USING SHORT FORM TEST must pass", function() {
ok( Aver.T("", true, ""), "testing 'true' using internal test plug USING SHORT FORM TEST must pass");
});
test( "sample test 'false' using internal test plug USING SHORT FORM TEST must fail", function() {
ok(!Aver.T("", false, ""), "testing 'false' using internal test plug USING SHORT FORM TEST must fail");
});
test( "sample test 'true' using internal test plug USING SHORT LONG TEST must pass", function() {
ok( Aver.WhenTesting("").ToMakeSure(true).Is(true).OtherwiseFailBecause(""), "testing 'true' using internal test plug USING LONG FORM TEST must pass");
});
test( "sample test 'false' using internal test plug USING LONG FORM TEST must fail", function() {
ok(!Aver.WhenTesting("").ToMakeSure(false).Is(true).OtherwiseFailBecause(""), "testing 'false' using internal test plug USING LONG FORM TEST must fail");
});
test( "when a display plugin is present, display plugin should be invoked to create the display after the SHORT form test has been executed", function() {
setUpSampleDisplayPlugin();
Aver.T("", false, "");
ok(WasDisplayCalled, "Display plugin should be called after invoking the SHORT form test");
});
test( "when a display plugin is present, display plugin should be invoked to create the display after the LONG form test has been executed", function() {
setUpSampleDisplayPlugin();
Aver.WhenTesting("").ToMakeSure(true).Is(true).OtherwiseFailBecause("");
ok(WasDisplayCalled, "Display plugin should be called after invoking the LONG form test");
});
test( "when a display plugin is present, display plugin should NOT be invoked to create the display before test has been executed", function() {
setUpSampleDisplayPlugin();
ok(!WasDisplayCalled, "Display plugin should NOT be called before invoking the short form test");
});
test( "when a test plug "+nameOfSampleTestPlug+" is present, "+nameOfSampleTestPlug+" method should be NOT! invoked after the SHORT form test has been executed", function() {
setUpSampleTestPlug();
Aver.T("", false, "");
ok(!WasTestPlugCalled, " "+nameOfSampleTestPlug+" method should be called after invoking the SHORT form test");
});
test( "when a test plug "+nameOfSampleTestPlug+" is present, "+nameOfSampleTestPlug+" method should be invoked after the LONG form test has been executed", function() {
setUpSampleTestPlug();
Aver.WhenTesting("").ToMakeSure(true)[nameOfSampleTestPlug](true).OtherwiseFailBecause("");
ok(WasTestPlugCalled, " "+nameOfSampleTestPlug+" method should be called after invoking the LONG form test");
});
test( "when a test plug "+nameOfSampleTestPlug+" is present, "+nameOfSampleTestPlug+" method should NOT be invoked before test has been executed", function() {
setUpSampleTestPlug();
ok(!WasTestPlugCalled, ""+nameOfSampleTestPlug+" method should NOT be called before invoking the short form test");
});
test( "when a test plug "+nameOfSampleTestPlug+" is present, correct actualValue parameter must be passed to the testplug "+nameOfSampleTestPlug+" when test is invocked", function() {
setUpSampleTestPlug();
var actualValue="12345";
var expectedValue="678910";
setUpSampleTestPlug();
Aver.WhenTesting("").ToMakeSure(actualValue)[nameOfSampleTestPlug](expectedValue).OtherwiseFailBecause("");
ok(actualValue===passedActualValue, "Correct actual value must be passed to the testplugs when test is invoked");
});
test( "when a test plug "+nameOfSampleTestPlug+" is present, correct expectedValue parameter must be passed to the testplug "+nameOfSampleTestPlug+" when test is invocked", function() {
setUpSampleTestPlug();
var actualValue="12345";
var expectedValue="678910";
setUpSampleTestPlug();
Aver.WhenTesting("").ToMakeSure(actualValue)[nameOfSampleTestPlug](expectedValue).OtherwiseFailBecause("");
ok(expectedValue===passedExpectedValue, " Correct expected value must be passed to the testplugs when test is invoked");
});
test( "The current version number of the script should be obtainable in global version object in string format", function() {
var current_version= Aver.version;
ok(!(current_version===undefined), " current version number must be available");
});
test( "version number must not be empty", function() {
var current_version= Aver.version;
ok(!(current_version.length===0), " current version number cannot be empty");
});
/*
still looking into these tests
test( "Testing some weired scenarios of EQUALITY WHERE var x={} AND var y={} AND var z=x then It is expected that equality test among x,y and z will be positive", function() {
var x={};
var y={};
var z=x;
ok(Aver.T("x===y", x===y, "inconclusive")," Expected x===y in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y===z", y===z, "inconclusive")," Expected y===z in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("z===x", z===x, "inconclusive")," Expected z===x in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("x==={}", x==={}, "inconclusive")," Expected x==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y==={}", y==={}, "inconclusive")," Expected y==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("z==={}", z==={},"inconclusive")," Expected z==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("x==y", x==y, "inconclusive")," Expected x==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y==z", y==z, "inconclusive")," Expected y==z in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("z==x", z==x,"inconclusive")," Expected z==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("x=={}", x=={}, "inconclusive")," Expected x=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y=={}", y=={},"inconclusive")," Expected y=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T(" z=={}", z=={},"inconclusive")," Expected z=={} in case where WHEN var x={} AND var y={} AND var z=x ");
});
test( "Testing scenarios of EQUALITY WHERE var x={} AND var y={} AND var z=x directly with QUnit", function() {
var x={};
var y={};
var z=x;
ok( x===y," with QUnit Expected x===y in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y===z," with QUnit Expected y===z in case where WHEN var x={} AND var y={} AND var z=x ");
ok( z===x," with QUnit Expected z===x in case where WHEN var x={} AND var y={} AND var z=x ");
ok( x==={}," with QUnit Expected x==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y==={}," with QUnit Expected y==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok( z==={}," with QUnit Expected z==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(x==y," with QUnit Expected x==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y==z," with QUnit Expected y==z in case where WHEN var x={} AND var y={} AND var z=x ");
ok( z==x," with QUnit Expected z==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok( x=={}," with QUnit Expected x=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y=={}," with QUnit Expected y=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(z=={}," with QUnit Expected z=={} in case where WHEN var x={} AND var y={} AND var z=x ");
});
test( "Testing some weired scenarios of EQUALITY WHERE var x={a:1} AND var y={a:1} AND var z=x then It is expected that equality test among x,y and z will be positive", function() {
var x={a:1};
var y={a:1};
var z=x;
ok(Aver.T("x===y", x===y, "inconclusive")," Expected x===y in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y===z", y===z, "inconclusive")," Expected y===z in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("z===x", z===x, "inconclusive")," Expected z===x in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("x==={}", x==={}, "inconclusive")," Expected x==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y==={}", y==={}, "inconclusive")," Expected y==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("z==={}", z==={},"inconclusive")," Expected z==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("x==y", x==y, "inconclusive")," Expected x==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y==z", y==z, "inconclusive")," Expected y==z in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("z==x", z==x,"inconclusive")," Expected z==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("x=={}", x=={}, "inconclusive")," Expected x=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T("y=={}", y=={},"inconclusive")," Expected y=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(Aver.T(" z=={}", z=={},"inconclusive")," Expected z=={} in case where WHEN var x={} AND var y={} AND var z=x ");
});
test( "Testing scenarios of EQUALITY WHERE var x={a:1} AND var y={a:1} AND var z=x directly with QUnit", function() {
var x={a:1};
var y={a:1};
var z=x;
ok( x===y," with QUnit Expected x===y in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y===z," with QUnit Expected y===z in case where WHEN var x={} AND var y={} AND var z=x ");
ok( z===x," with QUnit Expected z===x in case where WHEN var x={} AND var y={} AND var z=x ");
ok( x==={}," with QUnit Expected x==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y==={}," with QUnit Expected y==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok( z==={}," with QUnit Expected z==={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(x==y," with QUnit Expected x==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y==z," with QUnit Expected y==z in case where WHEN var x={} AND var y={} AND var z=x ");
ok( z==x," with QUnit Expected z==y in case where WHEN var x={} AND var y={} AND var z=x ");
ok( x=={}," with QUnit Expected x=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok( y=={}," with QUnit Expected y=={} in case where WHEN var x={} AND var y={} AND var z=x ");
ok(z=={}," with QUnit Expected z=={} in case where WHEN var x={} AND var y={} AND var z=x ");
});
*/