@sprucelabs/test 7.7.267 → 7.7.271

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.
@@ -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;
@@ -1,4 +0,0 @@
1
- import AbstractSpruceTest from '../AbstractSpruceTest';
2
- export default class ErrorStackTest extends AbstractSpruceTest {
3
- protected static removesExpected(stack: string, expected: string): Promise<void>;
4
- }
@@ -1,51 +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 StackCleaner_1 = __importDefault(require("../StackCleaner"));
16
- class ErrorStackTest extends AbstractSpruceTest_1.default {
17
- static async removesExpected(stack, expected) {
18
- const cleaned = StackCleaner_1.default.clean(stack);
19
- assert_1.default.isEqual(cleaned, expected);
20
- }
21
- }
22
- __decorate([
23
- (0, decorators_1.default)('removes test files', `Error: You called will-fail!
24
- at Object.willFail (/Users/taylorromero/Development/SpruceLabs/spruce-test/src/assert.ts:53:17)
25
- at Function.canRemoveTestFiles (/Users/taylorromero/Development/SpruceLabs/spruce-test/src/__tests__/ErrorStack.test.ts:8:10)
26
- at Object.<anonymous> (/Users/taylorromero/Development/SpruceLabs/spruce-test/src/decorators.ts:36:11)
27
- at Object.asyncJestTest (/Users/taylorromero/Development/SpruceLabs/spruce-test/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:100:37)
28
- at /Users/taylorromero/Development/SpruceLabs/spruce-test/node_modules/jest-jasmine2/build/queueRunner.js:45:12
29
- at new Promise (<anonymous>)
30
- at mapper (/Users/taylorromero/Development/SpruceLabs/spruce-test/node_modules/jest-jasmine2/build/queueRunner.js:28:19)
31
- at /Users/taylorromero/Development/SpruceLabs/spruce-test/node_modules/jest-jasmine2/build/queueRunner.js:75:41
32
- at processTicksAndRejections (internal/process/task_queues.js:97:5)`, `Error: You called will-fail!
33
- at Function.canRemoveTestFiles (/Users/taylorromero/Development/SpruceLabs/spruce-test/src/__tests__/ErrorStack.test.ts:8:10)
34
- at new Promise (<anonymous>)`),
35
- (0, decorators_1.default)('drops babel crap', `TypeError: Cannot read property 'map' of undefined
36
- at Object (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/src/databases/mongo.utilities.ts:21:17)
37
- at Array.forEach (<anonymous>)
38
- at mapNestedIdValues (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/src/databases/mongo.utilities.ts:20:2)
39
- at Object.mongoUtil [as mapQuery] (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/src/databases/mongo.utilities.ts:11:27)
40
- at MongoDatabase.toMongo…
41
- at Generator.next (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/node_modules/regenerator-runtime/runtime.js:118:21)
42
- at asyncGeneratorStep (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
43
- at _next (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
44
- at processTicksAndRejections (internal/process/task_queues.js:97:5)`, `TypeError: Cannot read property 'map' of undefined
45
- at Object (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/src/databases/mongo.utilities.ts:21:17)
46
- at Array.forEach (<anonymous>)
47
- at mapNestedIdValues (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/src/databases/mongo.utilities.ts:20:2)
48
- at Object.mongoUtil [as mapQuery] (/Users/taylorromero/Development/SpruceLabs/spruce-mercury-api/src/databases/mongo.utilities.ts:11:27)
49
- at MongoDatabase.toMongo…`)
50
- ], ErrorStackTest, "removesExpected", null);
51
- exports.default = ErrorStackTest;
@@ -1,6 +0,0 @@
1
- import AbstractSpruceTest from '..';
2
- export default class StringifyTest extends AbstractSpruceTest {
3
- protected static dropInPlaceholders(obj: any, expected: any): void;
4
- protected static printsPlaceholderFields(obj: Record<string, any>, expected: string): void;
5
- protected static canRenderWithoutStrippingCharactorsInTestReporter(obj: any): void;
6
- }
@@ -1,148 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
- 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;
18
- return c > 3 && r && Object.defineProperty(target, key, r), r;
19
- };
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
27
- var __importDefault = (this && this.__importDefault) || function (mod) {
28
- return (mod && mod.__esModule) ? mod : { "default": mod };
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- const chalk_1 = __importDefault(require("chalk"));
32
- const __1 = __importStar(require(".."));
33
- const decorators_1 = __importDefault(require("../decorators"));
34
- const assert_utility_1 = __importStar(require("../utilities/assert.utility"));
35
- const teammate = {
36
- firstName: 'tay',
37
- };
38
- const team = {
39
- teammate: Object.assign({}, teammate),
40
- };
41
- team.teammate.team = team;
42
- const team2 = {
43
- teammate,
44
- teammate2: teammate,
45
- };
46
- const team3 = {
47
- teammate: Object.assign(Object.assign({}, teammate), { age: 100 }),
48
- coach: {
49
- name: {
50
- firstName: 'tay',
51
- age: 100,
52
- },
53
- },
54
- };
55
- class StringifyTest extends __1.default {
56
- static dropInPlaceholders(obj, expected) {
57
- const placholder = assert_utility_1.default.dropInPlaceholders(obj);
58
- __1.assert.isEqualDeep(placholder, expected);
59
- }
60
- static printsPlaceholderFields(obj, expected) {
61
- const stringified = assert_utility_1.default.stringify(obj);
62
- __1.assert.isEqual(stringified, '\n\n' + chalk_1.default.bold(assert_utility_1.default.replacePlaceholders(expected)) + '\n\n');
63
- }
64
- static canRenderWithoutStrippingCharactorsInTestReporter(obj) {
65
- process.stderr.write(assert_utility_1.default.stringify(obj));
66
- }
67
- }
68
- __decorate([
69
- (0, decorators_1.default)('placeholdering simple object', { test: true }, { test: true }),
70
- (0, decorators_1.default)('placeholdering object with null', { test: null }, { test: assert_utility_1.NULL_PLACEHOLDER }),
71
- (0, decorators_1.default)('placeholdering object with function', { test: () => { } }, { test: assert_utility_1.FUNCTION_PLACEHOLDER }),
72
- (0, decorators_1.default)('placeholdering circular object', team, {
73
- teammate: {
74
- firstName: 'tay',
75
- team: assert_utility_1.CIRCULAR_PLACEHOLDER,
76
- },
77
- }),
78
- (0, decorators_1.default)('placeholdering same object on same level', team2, {
79
- teammate: {
80
- firstName: 'tay',
81
- },
82
- teammate2: {
83
- firstName: 'tay',
84
- },
85
- }),
86
- (0, decorators_1.default)('placeholdering objects with same values at different levels', team3, {
87
- teammate: {
88
- firstName: 'tay',
89
- age: 100,
90
- },
91
- coach: {
92
- name: {
93
- firstName: 'tay',
94
- age: 100,
95
- },
96
- },
97
- })
98
- ], StringifyTest, "dropInPlaceholders", null);
99
- __decorate([
100
- (0, decorators_1.default)('one level deep (undefined)', {
101
- hello: 'world',
102
- undefined,
103
- }, `{
104
- "hello": "world",
105
- "undefined": "${assert_utility_1.UNDEFINED_PLACEHOLDER}"
106
- }`),
107
- (0, decorators_1.default)('one level deep (null)', {
108
- hello: 'world',
109
- null: null,
110
- }, `{
111
- "hello": "world",
112
- "null": "${assert_utility_1.NULL_PLACEHOLDER}"
113
- }`),
114
- (0, decorators_1.default)('two levels deep', {
115
- hello: 'world',
116
- undefinedDeep: {
117
- undefined,
118
- },
119
- }, `{
120
- "hello": "world",
121
- "undefinedDeep": {
122
- "undefined": "${assert_utility_1.UNDEFINED_PLACEHOLDER}"
123
- }
124
- }`),
125
- (0, decorators_1.default)('three levels deep', {
126
- hello: 'world',
127
- undefinedDeep: {
128
- undefinedDeepAgain: {
129
- undefined,
130
- },
131
- },
132
- }, `{
133
- "hello": "world",
134
- "undefinedDeep": {
135
- "undefinedDeepAgain": {
136
- "undefined": "${assert_utility_1.UNDEFINED_PLACEHOLDER}"
137
- }
138
- }
139
- }`),
140
- (0, decorators_1.default)('prints a function nicely', { hello: () => { } }, `{
141
- "hello": "${assert_utility_1.FUNCTION_PLACEHOLDER}"
142
- }`)
143
- ], StringifyTest, "printsPlaceholderFields", null);
144
- __decorate([
145
- decorators_1.default.skip('array looks good', ['hello', 'world']),
146
- decorators_1.default.skip('objects looks good', { hello: 'world' })
147
- ], StringifyTest, "canRenderWithoutStrippingCharactorsInTestReporter", null);
148
- exports.default = StringifyTest;
@@ -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
- }