@sprucelabs/test 7.7.268 → 7.7.272
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/build/__tests__/Assert.test.d.ts +0 -37
- package/build/__tests__/Assert.test.js +0 -535
- package/build/__tests__/SpruceTest.test.d.ts +0 -12
- package/build/__tests__/SpruceTest.test.js +0 -70
- package/build/__tests__/StackCleaner.test.d.ts +0 -4
- package/build/__tests__/StackCleaner.test.js +0 -51
- package/build/__tests__/Stringify.test.d.ts +0 -6
- package/build/__tests__/Stringify.test.js +0 -148
- package/build/esm/__tests__/Assert.test.d.ts +0 -37
- package/build/esm/__tests__/Assert.test.js +0 -562
- package/build/esm/__tests__/SpruceTest.test.d.ts +0 -12
- package/build/esm/__tests__/SpruceTest.test.js +0 -91
- package/build/esm/__tests__/StackCleaner.test.d.ts +0 -4
- package/build/esm/__tests__/StackCleaner.test.js +0 -56
- package/build/esm/__tests__/Stringify.test.d.ts +0 -6
- package/build/esm/__tests__/Stringify.test.js +0 -123
|
@@ -1,562 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import AbstractSpruceTest from '../AbstractSpruceTest.js';
|
|
17
|
-
import assert from '../assert.js';
|
|
18
|
-
import test from '../decorators.js';
|
|
19
|
-
import assertUtil from '../utilities/assert.utility.js';
|
|
20
|
-
export default class AssertTest extends AbstractSpruceTest {
|
|
21
|
-
static canHandleAsyncThrows() {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
let hitError = false;
|
|
24
|
-
yield assert.doesThrowAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return new Promise(() => {
|
|
26
|
-
hitError = true;
|
|
27
|
-
throw new Error('should catch');
|
|
28
|
-
});
|
|
29
|
-
}));
|
|
30
|
-
assert.isTrue(hitError);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static canDetectNoErrorThrown() {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
let hitCallback = true;
|
|
36
|
-
let detectedNoThrow = false;
|
|
37
|
-
try {
|
|
38
|
-
assert.doesThrow(() => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
hitCallback = true;
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
detectedNoThrow = true;
|
|
44
|
-
assert.isTruthy(err);
|
|
45
|
-
}
|
|
46
|
-
assert.isTrue(hitCallback);
|
|
47
|
-
assert.isTrue(detectedNoThrow);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
static isEqual() {
|
|
51
|
-
assert.doesThrow(() => assert.isEqual('hello', 'world'), /not equal/);
|
|
52
|
-
assert.isEqual(1, 1);
|
|
53
|
-
}
|
|
54
|
-
static isAbove() {
|
|
55
|
-
assert.isAbove(10, 5);
|
|
56
|
-
assert.doesThrow(() => assert.isAbove(5, 10), /is not above/);
|
|
57
|
-
assert.doesThrow(() => assert.isAbove(undefined, 10), /is not a number/);
|
|
58
|
-
}
|
|
59
|
-
static isBelow() {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
assert.isBelow(5, 10);
|
|
62
|
-
assert.doesThrow(() => assert.isBelow(10, 5), /is not below/);
|
|
63
|
-
assert.doesThrow(() => assert.isBelow(undefined, 5), /is not a number/);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
static typeTests() {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
assert.isType('string');
|
|
69
|
-
assert.isType(123);
|
|
70
|
-
const myCustomObj = {
|
|
71
|
-
testStr: 'blah',
|
|
72
|
-
};
|
|
73
|
-
assert.isType(myCustomObj);
|
|
74
|
-
assert.areSameType(true, true);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
static canMatchErrorByString() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
assert.doesThrow(() => {
|
|
80
|
-
throw new Error('Match on string');
|
|
81
|
-
}, 'on string');
|
|
82
|
-
yield assert.doesThrowAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
throw new Error('canMatchErrorByString: Match on string');
|
|
84
|
-
}), 'on string');
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
static doesNotMatchErrorByBadString() {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
let errorThrown = false;
|
|
90
|
-
try {
|
|
91
|
-
assert.doesThrow(() => {
|
|
92
|
-
throw new Error('doesNotMatchErrorByBadString: Match on string');
|
|
93
|
-
}, 'on string2');
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
errorThrown = true;
|
|
97
|
-
}
|
|
98
|
-
assert.isTrue(errorThrown);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
static throwMatchesErrorByRegex() {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
assert.doesThrow(() => {
|
|
104
|
-
throw new Error('Match on string');
|
|
105
|
-
}, /on STRING/i);
|
|
106
|
-
yield assert.doesThrowAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
throw new Error('Match on string');
|
|
108
|
-
}), /on STRING/i);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
static throwReturnsTheError() {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const err = assert.doesThrow(() => {
|
|
114
|
-
throw new Error('Match on string');
|
|
115
|
-
});
|
|
116
|
-
assert.isEqual(err.message, 'Match on string');
|
|
117
|
-
const err2 = yield assert.doesThrowAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
throw new Error('Match on string');
|
|
119
|
-
}));
|
|
120
|
-
assert.isEqual(err2.message, 'Match on string');
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
static doesNotMatchErrorByBadRegex() {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
let errorThrown = false;
|
|
126
|
-
try {
|
|
127
|
-
assert.doesThrow(() => {
|
|
128
|
-
throw new Error('Match on string');
|
|
129
|
-
}, /on string2/);
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
errorThrown = true;
|
|
133
|
-
}
|
|
134
|
-
assert.isTrue(errorThrown);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
static doesNotMatchErrorByBadRegexAsync() {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
let errorThrown = false;
|
|
140
|
-
try {
|
|
141
|
-
yield assert.doesThrowAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
throw new Error('Match on string');
|
|
143
|
-
}), /on string2/);
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
errorThrown = true;
|
|
147
|
-
}
|
|
148
|
-
assert.isTrue(errorThrown);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
static assertIsString() {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const path = (() => {
|
|
154
|
-
return 'test';
|
|
155
|
-
})();
|
|
156
|
-
assert.isString(path);
|
|
157
|
-
assert.isType(path);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
static includeAndDoesNotInclude(haystack, needle) {
|
|
161
|
-
assert.doesInclude(haystack, needle);
|
|
162
|
-
assert.doesThrow(() => assert.doesNotInclude(haystack, needle), /should not include/);
|
|
163
|
-
}
|
|
164
|
-
static doesIncludeThrowsAsExpected(haystack, needle, matcher) {
|
|
165
|
-
const err = assert.doesThrow(() => assert.doesInclude(haystack, needle), matcher);
|
|
166
|
-
assert.doesNotInclude(err.message, 'undefined');
|
|
167
|
-
}
|
|
168
|
-
static hasAllFunctionsAndPasses() {
|
|
169
|
-
const obj = { func1: () => { }, func2() { }, foo: 'bar' };
|
|
170
|
-
assert.hasAllFunctions(obj, ['func1', 'func2']);
|
|
171
|
-
}
|
|
172
|
-
static hasAllFunctionsAndFails() {
|
|
173
|
-
const obj = { func1: () => { }, func2() { }, foo: 'bar' };
|
|
174
|
-
let errorHit = false;
|
|
175
|
-
try {
|
|
176
|
-
assert.hasAllFunctions(obj, ['func1', 'func3']);
|
|
177
|
-
}
|
|
178
|
-
catch (err) {
|
|
179
|
-
errorHit = true;
|
|
180
|
-
assert.doesInclude(err.message, 'func3');
|
|
181
|
-
}
|
|
182
|
-
assert.isTrue(errorHit);
|
|
183
|
-
}
|
|
184
|
-
static doesThrowIncludesOriginalStackTrace() {
|
|
185
|
-
function throwError() {
|
|
186
|
-
throw new Error('taco');
|
|
187
|
-
}
|
|
188
|
-
try {
|
|
189
|
-
throwError();
|
|
190
|
-
}
|
|
191
|
-
catch (err) {
|
|
192
|
-
const errWithStack = assert.doesThrow(() => assertUtil.checkDoesThrowError(/bravo/, err), /taco/);
|
|
193
|
-
assert.doesInclude(errWithStack.message, /at new Promise/);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
static isTruthy() {
|
|
197
|
-
const run = () => {
|
|
198
|
-
return 'test';
|
|
199
|
-
};
|
|
200
|
-
const value = run();
|
|
201
|
-
assert.isTruthy(value);
|
|
202
|
-
assert.isType(value);
|
|
203
|
-
assert.doesThrow(() => assert.isTruthy(false), /is not truthy/);
|
|
204
|
-
assert.doesThrow(() => assert.isTruthy(undefined), /is not truthy/);
|
|
205
|
-
assert.doesThrow(() => assert.isTruthy(null), /is not truthy/);
|
|
206
|
-
assert.doesThrow(() => assert.isTruthy(0), /is not truthy/);
|
|
207
|
-
}
|
|
208
|
-
static isFalsy() {
|
|
209
|
-
assert.isFalsy(null);
|
|
210
|
-
assert.isFalsy(0);
|
|
211
|
-
assert.isFalsy(undefined);
|
|
212
|
-
assert.isFalsy(false);
|
|
213
|
-
assert.doesThrow(() => assert.isFalsy(1), /is not falsy/);
|
|
214
|
-
assert.doesThrow(() => assert.isFalsy('undefined'), /is not falsy/);
|
|
215
|
-
}
|
|
216
|
-
static isString() {
|
|
217
|
-
assert.isString('test');
|
|
218
|
-
assert.doesThrow(() => assert.isString(true), 'not a string');
|
|
219
|
-
}
|
|
220
|
-
static isTrue() {
|
|
221
|
-
assert.isTrue(true);
|
|
222
|
-
assert.doesThrow(() => assert.isTrue(false), /does not equal(.*?)true/gis);
|
|
223
|
-
assert.doesThrow(() => assert.isTrue(undefined), /does not equal(.*?)true/gis);
|
|
224
|
-
}
|
|
225
|
-
static isFalse() {
|
|
226
|
-
assert.isFalse(false);
|
|
227
|
-
assert.doesThrow(() => assert.isFalse(true), /does not equal(.*?)false/gis);
|
|
228
|
-
assert.doesThrow(() => assert.isFalse(undefined), /does not equal(.*?)false/gis);
|
|
229
|
-
}
|
|
230
|
-
static deepEqual() {
|
|
231
|
-
assert.isEqualDeep({ test: true }, { test: true });
|
|
232
|
-
assert.doesThrow(() => assert.isEqualDeep({ test: true }, { test: false }), /true => false/);
|
|
233
|
-
assert.doesThrow(() => assert.isEqualDeep({ test: '1' }, { test: 1 }), /"1" => 1/);
|
|
234
|
-
}
|
|
235
|
-
static isUndefined() {
|
|
236
|
-
assert.isUndefined(undefined);
|
|
237
|
-
assert.doesThrow(() => assert.isUndefined(true), /not undefined/);
|
|
238
|
-
}
|
|
239
|
-
static isNotEqual() {
|
|
240
|
-
assert.isNotEqual(true, false);
|
|
241
|
-
assert.doesThrow(() => assert.isNotEqual('do', 'do'), /should not equal/);
|
|
242
|
-
}
|
|
243
|
-
static fail() {
|
|
244
|
-
assert.doesThrow(() => assert.fail('waka waka'), 'waka waka');
|
|
245
|
-
}
|
|
246
|
-
static isObject() {
|
|
247
|
-
assert.isObject({ test: true });
|
|
248
|
-
assert.doesThrow(() => assert.isObject(true), /not an object/gi);
|
|
249
|
-
}
|
|
250
|
-
static isLength() {
|
|
251
|
-
assert.isLength([], 0);
|
|
252
|
-
assert.isLength(['test'], 1);
|
|
253
|
-
assert.doesThrow(() => assert.isLength(['test'], 4), /expected length of/gi);
|
|
254
|
-
assert.doesThrow(() => assert.isLength(undefined, 4), /undefined/gi);
|
|
255
|
-
assert.doesThrow(() => assert.isLength(null, 4), /null/gi);
|
|
256
|
-
}
|
|
257
|
-
static isNull() {
|
|
258
|
-
assert.isNull(null);
|
|
259
|
-
assert.doesThrow(() => assert.isNull(false));
|
|
260
|
-
assert.doesThrow(() => assert.isNull(undefined));
|
|
261
|
-
}
|
|
262
|
-
static isExactType() {
|
|
263
|
-
const test = null;
|
|
264
|
-
assert.isExactType(true);
|
|
265
|
-
let test2;
|
|
266
|
-
assert.isExactType(true);
|
|
267
|
-
}
|
|
268
|
-
static isArray() {
|
|
269
|
-
assert.isArray([]);
|
|
270
|
-
assert.doesThrow(() => assert.isArray(true), /is not an array/);
|
|
271
|
-
let couldBeArray;
|
|
272
|
-
couldBeArray = [];
|
|
273
|
-
function test() {
|
|
274
|
-
assert.isArray(couldBeArray);
|
|
275
|
-
assert.isExactType(true);
|
|
276
|
-
}
|
|
277
|
-
test();
|
|
278
|
-
}
|
|
279
|
-
static isNumber() {
|
|
280
|
-
assert.doesThrow(() => assert.isNumber('test'));
|
|
281
|
-
assert.doesThrow(() => assert.isNumber('1'));
|
|
282
|
-
assert.isNumber(1);
|
|
283
|
-
assert.isNumber(2);
|
|
284
|
-
}
|
|
285
|
-
static printsNiceDiff() {
|
|
286
|
-
// assert.isEqualDeep(
|
|
287
|
-
// { test: true, taco: 'bell' },
|
|
288
|
-
// { test: false, burger: 'king' }
|
|
289
|
-
// )
|
|
290
|
-
assert.isFalsy([new Error('yay')]);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
__decorate([
|
|
294
|
-
test()
|
|
295
|
-
], AssertTest, "canHandleAsyncThrows", null);
|
|
296
|
-
__decorate([
|
|
297
|
-
test()
|
|
298
|
-
], AssertTest, "canDetectNoErrorThrown", null);
|
|
299
|
-
__decorate([
|
|
300
|
-
test()
|
|
301
|
-
], AssertTest, "isEqual", null);
|
|
302
|
-
__decorate([
|
|
303
|
-
test()
|
|
304
|
-
], AssertTest, "isAbove", null);
|
|
305
|
-
__decorate([
|
|
306
|
-
test()
|
|
307
|
-
], AssertTest, "isBelow", null);
|
|
308
|
-
__decorate([
|
|
309
|
-
test()
|
|
310
|
-
], AssertTest, "typeTests", null);
|
|
311
|
-
__decorate([
|
|
312
|
-
test()
|
|
313
|
-
], AssertTest, "canMatchErrorByString", null);
|
|
314
|
-
__decorate([
|
|
315
|
-
test()
|
|
316
|
-
], AssertTest, "doesNotMatchErrorByBadString", null);
|
|
317
|
-
__decorate([
|
|
318
|
-
test()
|
|
319
|
-
], AssertTest, "throwMatchesErrorByRegex", null);
|
|
320
|
-
__decorate([
|
|
321
|
-
test()
|
|
322
|
-
], AssertTest, "throwReturnsTheError", null);
|
|
323
|
-
__decorate([
|
|
324
|
-
test()
|
|
325
|
-
], AssertTest, "doesNotMatchErrorByBadRegex", null);
|
|
326
|
-
__decorate([
|
|
327
|
-
test()
|
|
328
|
-
], AssertTest, "doesNotMatchErrorByBadRegexAsync", null);
|
|
329
|
-
__decorate([
|
|
330
|
-
test('asserts is string (test will pass, types will fail)')
|
|
331
|
-
], AssertTest, "assertIsString", null);
|
|
332
|
-
__decorate([
|
|
333
|
-
test('include uses string to match string', 'hello world', 'world'),
|
|
334
|
-
test('assert regex on string', 'hello world', /world/gi),
|
|
335
|
-
test('assert regex obj on string', 'hello world', new RegExp('world', 'gis')),
|
|
336
|
-
test('include uses partial and matches 0th level', { hello: 'world', taco: 'bell' }, { taco: 'bell' }),
|
|
337
|
-
test('include can find string as value on 0th level', { hello: 'world', taco: 'bell' }, 'bell'),
|
|
338
|
-
test('include can find scalar on 1st level', { hello: 'world', taco: 'bell', flavor: { cheese: true, buffalo: true } }, { 'flavor.cheese': true }),
|
|
339
|
-
test('include can find scalar on 2nd level', {
|
|
340
|
-
hello: 'world',
|
|
341
|
-
taco: 'bell',
|
|
342
|
-
flavor: { cheese: { size: 'large', buffalo: true } },
|
|
343
|
-
}, { 'flavor.cheese.size': 'large' }),
|
|
344
|
-
test('include can find object on 2nd level', {
|
|
345
|
-
hello: 'world',
|
|
346
|
-
taco: 'bell',
|
|
347
|
-
flavor: { cheese: { size: 'large', buffalo: { wing: true } } },
|
|
348
|
-
}, { 'flavor.cheese.buffalo': { wing: true } }),
|
|
349
|
-
test('include can search inside array with index', {
|
|
350
|
-
flavors: [{ cheese: true }, { peperoni: true }],
|
|
351
|
-
}, { 'flavors[0].cheese': true }),
|
|
352
|
-
test('include can search inside array without index', {
|
|
353
|
-
flavors: [{ cheese: true }, { peperoni: true }],
|
|
354
|
-
}, { 'flavors[].peperoni': true }),
|
|
355
|
-
test('include can search inside array without index', {
|
|
356
|
-
flavors: [
|
|
357
|
-
{ size: 'large', toppings: [{ meat: true }, { cheese: true }] },
|
|
358
|
-
{ size: 'small' },
|
|
359
|
-
],
|
|
360
|
-
}, { 'flavors[].toppings[].meat': true }),
|
|
361
|
-
test('include can search array without index', [{ cheese: true }, { meat: true }], { meat: true }),
|
|
362
|
-
test('include can match on partial object', { cheese: true, meat: true }, {
|
|
363
|
-
meat: true,
|
|
364
|
-
}),
|
|
365
|
-
test('include can search array without index', [{ cheese: true }, { meat: true }], { '[].meat': true }),
|
|
366
|
-
test('include can search array without index', [{ cheese: true }, { meat: true }], { meat: true }),
|
|
367
|
-
test('include matches partial object in array', [
|
|
368
|
-
{
|
|
369
|
-
name: 'schemas.types.ts',
|
|
370
|
-
description: 'Every schema you need based on all your contracts',
|
|
371
|
-
path: '/var/folders/qw/v2bfr0c94bn37vclwvcltsj40000gn/tmp/5b49b673-7df0-4edd-ba9d-683a69a70f72/src/.spruce/schemas/schemas.types.ts',
|
|
372
|
-
action: 'updated',
|
|
373
|
-
},
|
|
374
|
-
], {
|
|
375
|
-
action: 'updated',
|
|
376
|
-
}),
|
|
377
|
-
test('include matches deep equal on object with nested object in array', [
|
|
378
|
-
{
|
|
379
|
-
name: 'schemas.types.ts',
|
|
380
|
-
description: 'Every schema you need based on all your contracts',
|
|
381
|
-
path: '/var/folders/qw/v2bfr0c94bn37vclwvcltsj40000gn/tmp/5b49b673-7df0-4edd-ba9d-683a69a70f72/src/.spruce/schemas/schemas.types.ts',
|
|
382
|
-
action: 'updated',
|
|
383
|
-
deep: {
|
|
384
|
-
foo: 'bar',
|
|
385
|
-
},
|
|
386
|
-
},
|
|
387
|
-
], {
|
|
388
|
-
name: 'schemas.types.ts',
|
|
389
|
-
description: 'Every schema you need based on all your contracts',
|
|
390
|
-
path: '/var/folders/qw/v2bfr0c94bn37vclwvcltsj40000gn/tmp/5b49b673-7df0-4edd-ba9d-683a69a70f72/src/.spruce/schemas/schemas.types.ts',
|
|
391
|
-
action: 'updated',
|
|
392
|
-
deep: {
|
|
393
|
-
foo: 'bar',
|
|
394
|
-
},
|
|
395
|
-
}),
|
|
396
|
-
test('include matches deep equal on nested object in array', [
|
|
397
|
-
{
|
|
398
|
-
name: 'schemas.types.ts',
|
|
399
|
-
description: 'Every schema you need based on all your contracts',
|
|
400
|
-
path: '/var/folders/qw/v2bfr0c94bn37vclwvcltsj40000gn/tmp/5b49b673-7df0-4edd-ba9d-683a69a70f72/src/.spruce/schemas/schemas.types.ts',
|
|
401
|
-
action: 'updated',
|
|
402
|
-
deep: {
|
|
403
|
-
foo: 'bar',
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
], {
|
|
407
|
-
name: 'schemas.types.ts',
|
|
408
|
-
deep: {
|
|
409
|
-
foo: 'bar',
|
|
410
|
-
},
|
|
411
|
-
}),
|
|
412
|
-
test('include matches object props', {
|
|
413
|
-
results: {
|
|
414
|
-
errors: [new Error('test'), new Error('test2')],
|
|
415
|
-
},
|
|
416
|
-
}, {
|
|
417
|
-
'results.errors[].stack': 'test2',
|
|
418
|
-
}),
|
|
419
|
-
test('include matches object props against regex', {
|
|
420
|
-
results: {
|
|
421
|
-
errors: [new Error('test'), new Error('test2')],
|
|
422
|
-
},
|
|
423
|
-
}, {
|
|
424
|
-
'results.errors[].stack': /test[1|2]/,
|
|
425
|
-
}),
|
|
426
|
-
test('include matches when passed an array and matching against object with numbers', [6, 7], 7),
|
|
427
|
-
test('include matches object with array property in array of objects', [
|
|
428
|
-
{
|
|
429
|
-
methodName: 'use',
|
|
430
|
-
args: [null],
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
methodName: 'on',
|
|
434
|
-
args: ['confirm-pin', null],
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
methodName: 'on',
|
|
438
|
-
args: ['who-am-i', null],
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
methodName: 'on',
|
|
442
|
-
args: ['authenticate', null],
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
methodName: 'on',
|
|
446
|
-
args: ['can-listen', null],
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
methodName: 'emit',
|
|
450
|
-
args: ['test.what-an-event', null],
|
|
451
|
-
},
|
|
452
|
-
], {
|
|
453
|
-
methodName: 'emit',
|
|
454
|
-
args: ['test.what-an-event', null],
|
|
455
|
-
})
|
|
456
|
-
], AssertTest, "includeAndDoesNotInclude", null);
|
|
457
|
-
__decorate([
|
|
458
|
-
test('include fails as expected with strings', 'taco', 'bravo', /could not find(.*?)"bravo"/gis),
|
|
459
|
-
test('include fails as expected with regex obj on string', 'hello world', new RegExp('cheeseball', 'gis')),
|
|
460
|
-
test('include fails as expected matching string against object', { hello: 'world' }, 'taco', /Could not find(.*?)taco/gis),
|
|
461
|
-
test('include fails as expected matching string against object with array', {
|
|
462
|
-
flavors: [
|
|
463
|
-
{ size: 'large', toppings: [{ meat: true }, { cheese: true }] },
|
|
464
|
-
{ size: 'small' },
|
|
465
|
-
],
|
|
466
|
-
}, { 'flavors[].toppings[].meat': false }, /could not find match(.*?)false(.*?)at(.*?)toppings\[\]\.meat/gis),
|
|
467
|
-
test.only('include fails as expected matching string against nested object', {
|
|
468
|
-
cheese: { size: 'large', toppings: { meat: true } },
|
|
469
|
-
}, { 'cheese.toppings.stink': false }, /the path(.*?)cheese.toppings.stink(.*?)was not found in/gis),
|
|
470
|
-
test('include fails as expected by not showing full object if path matches but value differs', {
|
|
471
|
-
cheese: { size: 'large', toppings: { meat: true } },
|
|
472
|
-
}, { 'cheese.toppings.meat': false }, /expected(.*?)false(.*?)but found(.*?)true(.*?) at(.*?)cheese.toppings.meat/gis),
|
|
473
|
-
test("include fails when can't find in an array", [
|
|
474
|
-
{
|
|
475
|
-
name: 'schemas.types.ts',
|
|
476
|
-
description: 'Every schema you need based on all your contracts',
|
|
477
|
-
path: '/var/folders/qw/v2bfr0c94bn37vclwvcltsj40000gn/tmp/5b49b673-7df0-4edd-ba9d-683a69a70f72/src/.spruce/schemas/schemas.types.ts',
|
|
478
|
-
action: 'updated',
|
|
479
|
-
},
|
|
480
|
-
], {
|
|
481
|
-
action: 'star',
|
|
482
|
-
}, /could not find(.*?)"action": "star"/gis),
|
|
483
|
-
test("include fails when can't find in an array", [
|
|
484
|
-
{
|
|
485
|
-
name: 'schemas.types.ts',
|
|
486
|
-
description: 'Every schema you need based on all your contracts',
|
|
487
|
-
path: '/var/folders/qw/v2bfr0c94bn37vclwvcltsj40000gn/tmp/5b49b673-7df0-4edd-ba9d-683a69a70f72/src/.spruce/schemas/schemas.types.ts',
|
|
488
|
-
action: 'updated',
|
|
489
|
-
},
|
|
490
|
-
], {
|
|
491
|
-
name: 'schemas.types.ts',
|
|
492
|
-
action: '2',
|
|
493
|
-
}, /could not find(.*?)"name": "schemas.types.ts"/gis),
|
|
494
|
-
test('include fails object props against regex', {
|
|
495
|
-
results: {
|
|
496
|
-
errors: [new Error('test'), new Error('test2')],
|
|
497
|
-
},
|
|
498
|
-
}, {
|
|
499
|
-
'results.errors[].stack': /test3/,
|
|
500
|
-
}, /could not find match/i),
|
|
501
|
-
test('include fails when passed an array and matching against object', ['hey', 'there'], { name: 'hey', foo: 'bar' }, /could not find/i),
|
|
502
|
-
test('include fails when passed an array and matching against object with numbers', [6, 7], { name: 7, foo: 6 }, /could not find/i),
|
|
503
|
-
test('include matches when passed an array and matching against numbers', [6, 7], 9),
|
|
504
|
-
test('include fails when searching an object for a regex', { foo: 'bar', taco: 'bravo' }, /yummy/)
|
|
505
|
-
], AssertTest, "doesIncludeThrowsAsExpected", null);
|
|
506
|
-
__decorate([
|
|
507
|
-
test()
|
|
508
|
-
], AssertTest, "hasAllFunctionsAndPasses", null);
|
|
509
|
-
__decorate([
|
|
510
|
-
test()
|
|
511
|
-
], AssertTest, "hasAllFunctionsAndFails", null);
|
|
512
|
-
__decorate([
|
|
513
|
-
test()
|
|
514
|
-
], AssertTest, "doesThrowIncludesOriginalStackTrace", null);
|
|
515
|
-
__decorate([
|
|
516
|
-
test()
|
|
517
|
-
], AssertTest, "isTruthy", null);
|
|
518
|
-
__decorate([
|
|
519
|
-
test()
|
|
520
|
-
], AssertTest, "isFalsy", null);
|
|
521
|
-
__decorate([
|
|
522
|
-
test()
|
|
523
|
-
], AssertTest, "isString", null);
|
|
524
|
-
__decorate([
|
|
525
|
-
test()
|
|
526
|
-
], AssertTest, "isTrue", null);
|
|
527
|
-
__decorate([
|
|
528
|
-
test()
|
|
529
|
-
], AssertTest, "isFalse", null);
|
|
530
|
-
__decorate([
|
|
531
|
-
test()
|
|
532
|
-
], AssertTest, "deepEqual", null);
|
|
533
|
-
__decorate([
|
|
534
|
-
test()
|
|
535
|
-
], AssertTest, "isUndefined", null);
|
|
536
|
-
__decorate([
|
|
537
|
-
test()
|
|
538
|
-
], AssertTest, "isNotEqual", null);
|
|
539
|
-
__decorate([
|
|
540
|
-
test()
|
|
541
|
-
], AssertTest, "fail", null);
|
|
542
|
-
__decorate([
|
|
543
|
-
test()
|
|
544
|
-
], AssertTest, "isObject", null);
|
|
545
|
-
__decorate([
|
|
546
|
-
test()
|
|
547
|
-
], AssertTest, "isLength", null);
|
|
548
|
-
__decorate([
|
|
549
|
-
test()
|
|
550
|
-
], AssertTest, "isNull", null);
|
|
551
|
-
__decorate([
|
|
552
|
-
test()
|
|
553
|
-
], AssertTest, "isExactType", null);
|
|
554
|
-
__decorate([
|
|
555
|
-
test()
|
|
556
|
-
], AssertTest, "isArray", null);
|
|
557
|
-
__decorate([
|
|
558
|
-
test()
|
|
559
|
-
], AssertTest, "isNumber", null);
|
|
560
|
-
__decorate([
|
|
561
|
-
test.skip('Example of pretty print. Remove skip() to see. Always fails.')
|
|
562
|
-
], AssertTest, "printsNiceDiff", null);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import AbstractSpruceTest from '../AbstractSpruceTest';
|
|
2
|
-
export default class SpruceTest extends AbstractSpruceTest {
|
|
3
|
-
protected static beforeAll(): Promise<void>;
|
|
4
|
-
protected static beforeEach(): Promise<void>;
|
|
5
|
-
protected static afterEach(): Promise<void>;
|
|
6
|
-
protected static doesCallBeforeAll(): Promise<void>;
|
|
7
|
-
protected static basicPassingTest(): Promise<void>;
|
|
8
|
-
protected static canAccessVarsFromDecorator(hello: string, world: string): Promise<void>;
|
|
9
|
-
protected static calledBeforeAndAfterEach(): Promise<void>;
|
|
10
|
-
protected static asyncDebuggerWaits(): Promise<void>;
|
|
11
|
-
protected static todo(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import AbstractSpruceTest from '../AbstractSpruceTest.js';
|
|
17
|
-
import assert from '../assert.js';
|
|
18
|
-
import test from '../decorators.js';
|
|
19
|
-
let beforeAllCount = 0;
|
|
20
|
-
let beforeEachCount = 0;
|
|
21
|
-
let afterEachCount = 0;
|
|
22
|
-
export default class SpruceTest extends AbstractSpruceTest {
|
|
23
|
-
static beforeAll() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
beforeAllCount += 1;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
static beforeEach() {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
beforeEachCount += 1;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static afterEach() {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
afterEachCount += 1;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
static doesCallBeforeAll() {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
assert.isEqual(beforeAllCount, 1);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
static basicPassingTest() {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
assert.isTrue(true);
|
|
46
|
-
assert.isFalse(false);
|
|
47
|
-
assert.isEqual(5, 5, `Thing's don't equal`);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
static canAccessVarsFromDecorator(hello, world) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
assert.isEqual(hello, 'hello');
|
|
53
|
-
assert.isEqual(world, 'world');
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
static calledBeforeAndAfterEach() {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
assert.isEqual(beforeEachCount, 4);
|
|
59
|
-
assert.isEqual(afterEachCount, 3);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
static asyncDebuggerWaits() {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const results = yield this.wait(1000);
|
|
65
|
-
assert.isTruthy(results);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
static todo() {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
// TODO
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
__decorate([
|
|
75
|
-
test()
|
|
76
|
-
], SpruceTest, "doesCallBeforeAll", null);
|
|
77
|
-
__decorate([
|
|
78
|
-
test()
|
|
79
|
-
], SpruceTest, "basicPassingTest", null);
|
|
80
|
-
__decorate([
|
|
81
|
-
test('can pass variables to test handler from decorator', 'hello', 'world')
|
|
82
|
-
], SpruceTest, "canAccessVarsFromDecorator", null);
|
|
83
|
-
__decorate([
|
|
84
|
-
test()
|
|
85
|
-
], SpruceTest, "calledBeforeAndAfterEach", null);
|
|
86
|
-
__decorate([
|
|
87
|
-
test()
|
|
88
|
-
], SpruceTest, "asyncDebuggerWaits", null);
|
|
89
|
-
__decorate([
|
|
90
|
-
test.todo('can create a TODO test')
|
|
91
|
-
], SpruceTest, "todo", null);
|