@sprucelabs/test 7.7.338 → 7.7.339
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/build/assert.js
CHANGED
|
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const chalk_1 = __importDefault(require("chalk"));
|
|
7
7
|
const deep_equal_1 = __importDefault(require("deep-equal"));
|
|
8
|
-
const
|
|
8
|
+
const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
|
|
9
|
+
const isObjectLike_1 = __importDefault(require("lodash/isObjectLike"));
|
|
9
10
|
const ts_expect_1 = require("ts-expect");
|
|
10
11
|
const variable_diff_1 = __importDefault(require("variable-diff"));
|
|
11
12
|
const assert_utility_1 = __importDefault(require("./utilities/assert.utility"));
|
|
@@ -90,7 +91,7 @@ const spruceAssert = {
|
|
|
90
91
|
this.isEqual(actual, false, message);
|
|
91
92
|
},
|
|
92
93
|
isObject(actual, message) {
|
|
93
|
-
if (!(0,
|
|
94
|
+
if (!(0, isObjectLike_1.default)(actual)) {
|
|
94
95
|
throw this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not an object`);
|
|
95
96
|
}
|
|
96
97
|
},
|
|
@@ -125,10 +126,10 @@ const spruceAssert = {
|
|
|
125
126
|
const isNeedleRegex = needle instanceof RegExp;
|
|
126
127
|
if (typeof haystack === 'string' &&
|
|
127
128
|
(isNeedleString || isNeedleRegex) &&
|
|
128
|
-
haystack.search(isNeedleString ? (0,
|
|
129
|
+
haystack.search(isNeedleString ? (0, escapeRegExp_1.default)(needle) : needle) > -1) {
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
131
|
-
const isHaystackObject = (0,
|
|
132
|
+
const isHaystackObject = (0, isObjectLike_1.default)(haystack);
|
|
132
133
|
const { needleHasArrayNotation, path, expected } = assert_utility_1.default.parseIncludeNeedle(needle);
|
|
133
134
|
if (Array.isArray(haystack)) {
|
|
134
135
|
let cleanedNeedle = needle;
|
|
@@ -140,7 +141,7 @@ const spruceAssert = {
|
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
|
-
if (isHaystackObject && (0,
|
|
144
|
+
if (isHaystackObject && (0, isObjectLike_1.default)(needle)) {
|
|
144
145
|
try {
|
|
145
146
|
//@ts-ignore
|
|
146
147
|
this.isEqualDeep(haystack, needle);
|
|
@@ -154,7 +155,7 @@ const spruceAssert = {
|
|
|
154
155
|
}
|
|
155
156
|
if (!Array.isArray(haystack) &&
|
|
156
157
|
isHaystackObject &&
|
|
157
|
-
(0,
|
|
158
|
+
(0, isObjectLike_1.default)(needle) &&
|
|
158
159
|
Object.keys(needle).length === 1 &&
|
|
159
160
|
!needleHasArrayNotation &&
|
|
160
161
|
path) {
|
|
@@ -179,7 +180,7 @@ const spruceAssert = {
|
|
|
179
180
|
}
|
|
180
181
|
return;
|
|
181
182
|
}
|
|
182
|
-
if (isHaystackObject && (0,
|
|
183
|
+
if (isHaystackObject && (0, isObjectLike_1.default)(needle) && path) {
|
|
183
184
|
const { actualBeforeArray, pathAfterFirstArray } = assert_utility_1.default.splitPathBasedOnArrayNotation(path, haystack);
|
|
184
185
|
if (!Array.isArray(actualBeforeArray)) {
|
|
185
186
|
this.fail(msg);
|
package/build/esm/assert.js
CHANGED
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import chalk from 'chalk';
|
|
11
11
|
import deepEqual from 'deep-equal';
|
|
12
|
-
import
|
|
12
|
+
import escapeRegExp from 'lodash/escapeRegExp.js';
|
|
13
|
+
import isObjectLike from 'lodash/isObjectLike.js';
|
|
13
14
|
import { expectType } from 'ts-expect';
|
|
14
15
|
import diff from 'variable-diff';
|
|
15
16
|
import assertUtil from './utilities/assert.utility.js';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import get from 'lodash/get.js';
|
|
3
|
+
import includes from 'lodash/includes.js';
|
|
4
|
+
import isObject from 'lodash/isObject.js';
|
|
5
|
+
import isObjectLike from 'lodash/isObjectLike.js';
|
|
3
6
|
import AssertionError from '../AssertionError.js';
|
|
4
7
|
export const UNDEFINED_PLACEHOLDER = '_____________undefined_____________';
|
|
5
8
|
export const FUNCTION_PLACEHOLDER = '_____________function_____________';
|
|
@@ -5,7 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NULL_PLACEHOLDER = exports.CIRCULAR_PLACEHOLDER = exports.FUNCTION_PLACEHOLDER = exports.UNDEFINED_PLACEHOLDER = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const includes_1 = __importDefault(require("lodash/includes"));
|
|
10
|
+
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
11
|
+
const isObjectLike_1 = __importDefault(require("lodash/isObjectLike"));
|
|
9
12
|
const AssertionError_1 = __importDefault(require("../AssertionError"));
|
|
10
13
|
exports.UNDEFINED_PLACEHOLDER = '_____________undefined_____________';
|
|
11
14
|
exports.FUNCTION_PLACEHOLDER = '_____________function_____________';
|
|
@@ -58,7 +61,7 @@ const assertUtil = {
|
|
|
58
61
|
dropInPlaceholders(obj) {
|
|
59
62
|
const checkedObjects = [{ obj, depth: 0 }];
|
|
60
63
|
let updated = this.dropInPlaceholder(obj, (obj, depth) => {
|
|
61
|
-
if ((0,
|
|
64
|
+
if ((0, isObject_1.default)(obj) &&
|
|
62
65
|
checkedObjects.some((checked) => {
|
|
63
66
|
return checked.obj === obj && checked.depth < depth;
|
|
64
67
|
})) {
|
|
@@ -73,7 +76,7 @@ const assertUtil = {
|
|
|
73
76
|
return updated;
|
|
74
77
|
},
|
|
75
78
|
dropInPlaceholder(obj, checker, placeholder, depth = 1) {
|
|
76
|
-
if (!(0,
|
|
79
|
+
if (!(0, isObject_1.default)(obj)) {
|
|
77
80
|
return obj;
|
|
78
81
|
}
|
|
79
82
|
const updated = Array.isArray(obj) ? [] : {};
|
|
@@ -83,7 +86,7 @@ const assertUtil = {
|
|
|
83
86
|
// @ts-ignore
|
|
84
87
|
checker(obj[key], depth) ? placeholder : obj[key];
|
|
85
88
|
//@ts-ignore
|
|
86
|
-
if (typeof updated[key] !== 'function' && (0,
|
|
89
|
+
if (typeof updated[key] !== 'function' && (0, isObject_1.default)(updated[key])) {
|
|
87
90
|
//@ts-ignore
|
|
88
91
|
updated[key] = this.dropInPlaceholder(
|
|
89
92
|
//@ts-ignore
|
|
@@ -131,12 +134,12 @@ const assertUtil = {
|
|
|
131
134
|
if (!Object.prototype.hasOwnProperty.call(object, subProp)) {
|
|
132
135
|
return false;
|
|
133
136
|
}
|
|
134
|
-
if ((!(0,
|
|
137
|
+
if ((!(0, isObjectLike_1.default)(object[subProp]) || !(0, isObjectLike_1.default)(subObject[subProp])) &&
|
|
135
138
|
object[subProp] !== subObject[subProp]) {
|
|
136
139
|
return false;
|
|
137
140
|
}
|
|
138
|
-
if ((0,
|
|
139
|
-
(0,
|
|
141
|
+
if ((0, isObjectLike_1.default)(object[subProp]) &&
|
|
142
|
+
(0, isObjectLike_1.default)(subObject[subProp]) &&
|
|
140
143
|
!this.partialContains(object[subProp], subObject[subProp])) {
|
|
141
144
|
return false;
|
|
142
145
|
}
|
|
@@ -144,7 +147,7 @@ const assertUtil = {
|
|
|
144
147
|
return true;
|
|
145
148
|
},
|
|
146
149
|
valueAtPath(object, path) {
|
|
147
|
-
return (0,
|
|
150
|
+
return (0, get_1.default)(object, path);
|
|
148
151
|
},
|
|
149
152
|
parseIncludeNeedle(needle) {
|
|
150
153
|
const path = Object.keys(needle)[0];
|
|
@@ -167,7 +170,7 @@ const assertUtil = {
|
|
|
167
170
|
haystack.search(needle) > -1) {
|
|
168
171
|
passed = true;
|
|
169
172
|
}
|
|
170
|
-
if (isHaystackObject && (0,
|
|
173
|
+
if (isHaystackObject && (0, includes_1.default)(haystack, needle)) {
|
|
171
174
|
passed = true;
|
|
172
175
|
}
|
|
173
176
|
if (isHaystackObject && this.partialContains(haystack, needle)) {
|