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