yzt
2023-05-05 4c558c77a6a9d23f057f094c4dc3e315eabef497
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import { Check, FeatureDetection } from "../../Source/Cesium.js";
 
describe("Core/Check", function () {
  describe("type checks", function () {
    it("Check.typeOf.bool does not throw when passed a boolean", function () {
      expect(function () {
        Check.typeOf.bool("bool", true);
      }).not.toThrowDeveloperError();
    });
 
    it("Check.typeOf.bool throws when passed a non-boolean", function () {
      expect(function () {
        Check.typeOf.bool("mockName", {});
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bool("mockName", []);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bool("mockName", 1);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bool("mockName", "snth");
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bool("mockName", function () {
          return true;
        });
      }).toThrowDeveloperError();
    });
 
    it("Check.typeOf.bigint does not throw when passed a bigint", function () {
      if (!FeatureDetection.supportsBigInt()) {
        return;
      }
 
      expect(function () {
        Check.typeOf.bigint("bigint", BigInt()); // eslint-disable-line
      }).not.toThrowDeveloperError();
    });
 
    it("Check.typeOf.bigint throws when passed a non-bigint", function () {
      if (!FeatureDetection.supportsBigInt()) {
        return;
      }
 
      expect(function () {
        Check.typeOf.bigint("mockName", {});
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bigint("mockName", []);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bigint("mockName", 1);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bigint("mockName", true);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bigint("mockName", "snth");
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.bigint("mockName", function () {
          return true;
        });
      }).toThrowDeveloperError();
    });
 
    it("Check.typeOf.func does not throw when passed a function", function () {
      expect(function () {
        Check.typeOf.func("mockName", function () {
          return true;
        });
      }).not.toThrowDeveloperError();
    });
 
    it("Check.typeOf.func throws when passed a non-function", function () {
      expect(function () {
        Check.typeOf.func("mockName", {});
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.func("mockName", [2]);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.func("mockName", 1);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.func("mockName", "snth");
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.func("mockName", true);
      }).toThrowDeveloperError();
    });
 
    it("Check.typeOf.object does not throw when passed object", function () {
      expect(function () {
        Check.typeOf.object("mockName", {});
      }).not.toThrowDeveloperError();
    });
 
    it("Check.typeOf.object throws when passed non-object", function () {
      expect(function () {
        Check.typeOf.object("mockName", "snth");
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.object("mockName", true);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.object("mockName", 1);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.object("mockName", function () {
          return true;
        });
      }).toThrowDeveloperError();
    });
 
    it("Check.typeOf.number does not throw when passed number", function () {
      expect(function () {
        Check.typeOf.number("mockName", 2);
      }).not.toThrowDeveloperError();
    });
 
    it("Check.typeOf.number throws when passed non-number", function () {
      expect(function () {
        Check.typeOf.number("mockName", "snth");
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.number("mockName", true);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.number("mockName", {});
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.number("mockName", [2]);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.number("mockName", function () {
          return true;
        });
      }).toThrowDeveloperError();
    });
 
    it("Check.typeOf.string does not throw when passed a string", function () {
      expect(function () {
        Check.typeOf.string("mockName", "s");
      }).not.toThrowDeveloperError();
    });
 
    it("Check.typeOf.string throws on non-string", function () {
      expect(function () {
        Check.typeOf.string("mockName", {});
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.string("mockName", true);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.string("mockName", 1);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.string("mockName", [2]);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.string("mockName", function () {
          return true;
        });
      }).toThrowDeveloperError();
    });
  });
 
  describe("Check.defined", function () {
    it("does not throw unless passed value that is undefined or null", function () {
      expect(function () {
        Check.defined("mockName", {});
      }).not.toThrowDeveloperError();
      expect(function () {
        Check.defined("mockName", []);
      }).not.toThrowDeveloperError();
      expect(function () {
        Check.defined("mockName", 2);
      }).not.toThrowDeveloperError();
      expect(function () {
        Check.defined("mockName", function () {
          return true;
        });
      }).not.toThrowDeveloperError();
      expect(function () {
        Check.defined("mockName", "snt");
      }).not.toThrowDeveloperError();
    });
 
    it("throws when passed undefined", function () {
      expect(function () {
        Check.defined("mockName", undefined);
      }).toThrowDeveloperError();
    });
  });
 
  describe("Check.typeOf.number.lessThan", function () {
    it("throws if test is equal to limit", function () {
      expect(function () {
        Check.typeOf.number.lessThan("mockName", 3, 3);
      }).toThrowDeveloperError();
    });
 
    it("throws if test is greater than limit", function () {
      expect(function () {
        Check.typeOf.number.lessThan("mockName", 4, 3);
      }).toThrowDeveloperError();
    });
 
    it("does not throw if test is less than limit", function () {
      expect(function () {
        Check.typeOf.number.lessThan("mockName", 2, 3);
      }).not.toThrowDeveloperError();
    });
  });
 
  describe("Check.typeOf.number.lessThanOrEquals", function () {
    it("throws if test is greater than limit", function () {
      expect(function () {
        Check.typeOf.number.lessThanOrEquals("mockName", 4, 3);
      }).toThrowDeveloperError();
    });
 
    it("does not throw if test is equal to limit", function () {
      expect(function () {
        Check.typeOf.number.lessThanOrEquals("mockName", 3, 3);
      }).not.toThrowDeveloperError();
    });
 
    it("does not throw if test is less than limit", function () {
      expect(function () {
        Check.typeOf.number.lessThanOrEquals("mockName", 2, 3);
      }).not.toThrowDeveloperError();
    });
  });
 
  describe("Check.typeOf.number.equals", function () {
    it("throws if either value is not a number", function () {
      expect(function () {
        Check.typeOf.number.equals("mockName1", "mockname2", "a", 3);
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.number.equals("mockName1", "mockname2", 3, "a");
      }).toThrowDeveloperError();
      expect(function () {
        Check.typeOf.number.equals("mockName1", "mockname2", "b", "a");
      }).toThrowDeveloperError();
    });
 
    it("throws if both the values are a number but not equal", function () {
      expect(function () {
        Check.typeOf.number.equals("mockName1", "mockName2", 1, 4);
      }).toThrowDeveloperError();
    });
 
    it("does not throw if both values are a number and are equal", function () {
      expect(function () {
        Check.typeOf.number.equal("mockName1", "mockName2", 3, 3);
      }).not.toThrowDeveloperError();
    });
  });
 
  describe("Check.typeOf.number.greaterThan", function () {
    it("throws if test is equal to limit", function () {
      expect(function () {
        Check.typeOf.number.greaterThan("mockName", 3, 3);
      }).toThrowDeveloperError();
    });
 
    it("throws if test is less than limit", function () {
      expect(function () {
        Check.typeOf.number.greaterThan("mockName", 2, 3);
      }).toThrowDeveloperError();
    });
 
    it("does not throw if test is greater than limit", function () {
      expect(function () {
        Check.typeOf.number.greaterThan("mockName", 4, 3);
      }).not.toThrowDeveloperError();
    });
  });
 
  describe("Check.typeOf.number.greaterThanOrEquals", function () {
    it("throws if test is less than limit", function () {
      expect(function () {
        Check.typeOf.number.greaterThanOrEquals("mockName", 2, 3);
      }).toThrowDeveloperError();
    });
 
    it("does not throw if test is equal to limit", function () {
      expect(function () {
        Check.typeOf.number.greaterThanOrEquals("mockName", 3, 3);
      }).not.toThrowDeveloperError();
    });
 
    it("does not throw if test is greater than limit", function () {
      expect(function () {
        Check.typeOf.number.greaterThanOrEquals("mockName", 4, 3);
      }).not.toThrowDeveloperError();
    });
  });
});