@sprucelabs/test-utils 3.0.390 → 3.0.394

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 +1 @@
1
- export { default as errorAssertUtil } from './utilities/errorAssert.utility';
1
+ export { default as errorAssert } from './utilities/errorAssert';
@@ -1 +1 @@
1
- export { default as errorAssertUtil } from './utilities/errorAssert.utility.js';
1
+ export { default as errorAssert } from './utilities/errorAssert.js';
@@ -0,0 +1,6 @@
1
+ import AbstractSpruceError from '@sprucelabs/error';
2
+ declare const errorAssert: {
3
+ assertError(error: Error | AbstractSpruceError<any>, expectedCode: string, expectedPartialOptions?: Record<string, any> | undefined): void;
4
+ stripFriendlyMessageFromOptions(options: Record<string, any> | Record<string, any>[]): Record<string, any> | Record<string, any>[];
5
+ };
6
+ export default errorAssert;
@@ -0,0 +1,67 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import AbstractSpruceError from '@sprucelabs/error';
13
+ import { assert, assertUtil } from '@sprucelabs/test';
14
+ import cloneDeep from 'lodash/cloneDeep.js';
15
+ function removeProps(obj, keys) {
16
+ if (obj instanceof Array) {
17
+ obj.forEach(function (item, idx) {
18
+ if (item instanceof AbstractSpruceError) {
19
+ obj[idx] = item = { options: item.options };
20
+ }
21
+ removeProps(item, keys);
22
+ });
23
+ }
24
+ else if (obj && typeof obj === 'object') {
25
+ Object.getOwnPropertyNames(obj).forEach(function (key) {
26
+ if (obj[key] instanceof AbstractSpruceError) {
27
+ obj[key] = { options: obj[key].options };
28
+ removeProps(obj[key], keys);
29
+ }
30
+ else if (keys.indexOf(key) !== -1) {
31
+ delete obj[key];
32
+ }
33
+ else {
34
+ removeProps(obj[key], keys);
35
+ }
36
+ });
37
+ }
38
+ }
39
+ const errorAssert = {
40
+ assertError(error, expectedCode, expectedPartialOptions) {
41
+ var _a, _b;
42
+ const spruceErr = error;
43
+ if (!(spruceErr instanceof AbstractSpruceError)) {
44
+ if (spruceErr instanceof Error || spruceErr.message) {
45
+ assertUtil.fail(`Did not receive a SpruceError, got:\n\nMessage: ${(_a = spruceErr.message) !== null && _a !== void 0 ? _a : '***missing***'}`, (_b = spruceErr.stack) !== null && _b !== void 0 ? _b : '');
46
+ }
47
+ else {
48
+ assertUtil.fail(`Did not receive a SpruceError, got: \n\n${assertUtil.stringify(error)}`);
49
+ }
50
+ }
51
+ if (spruceErr.options.code === expectedCode) {
52
+ if (expectedPartialOptions) {
53
+ assert.doesInclude(spruceErr.options, expectedPartialOptions);
54
+ }
55
+ }
56
+ else {
57
+ const _c = spruceErr.options, { code, friendlyMessage } = _c, options = __rest(_c, ["code", "friendlyMessage"]);
58
+ assertUtil.fail(`Invalid error code. Expected:\n\n'${expectedCode}'\n\nbut got:\n\nCode: '${code}'\nMessage: '${friendlyMessage !== null && friendlyMessage !== void 0 ? friendlyMessage : spruceErr.message}'\nOptions:${assertUtil.stringify(options)}`, spruceErr.stack);
59
+ }
60
+ },
61
+ stripFriendlyMessageFromOptions(options) {
62
+ const clone = cloneDeep(options);
63
+ removeProps(clone, ['friendlyMessage']);
64
+ return clone;
65
+ },
66
+ };
67
+ export default errorAssert;
@@ -1,6 +1,8 @@
1
- import AbstractSpruceError from '@sprucelabs/error';
1
+ /**
2
+ * @deprecated errorAssertUtil -> errorAssert
3
+ */
2
4
  declare const errorAssertUtil: {
3
- assertError(error: Error | AbstractSpruceError<any>, expectedCode: string, expectedPartialOptions?: Record<string, any> | undefined): void;
5
+ assertError(error: Error | import("@sprucelabs/error").default<any>, expectedCode: string, expectedPartialOptions?: Record<string, any> | undefined): void;
4
6
  stripFriendlyMessageFromOptions(options: Record<string, any> | Record<string, any>[]): Record<string, any> | Record<string, any>[];
5
7
  };
6
8
  export default errorAssertUtil;
@@ -1,67 +1,6 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import AbstractSpruceError from '@sprucelabs/error';
13
- import { assert, assertUtil } from '@sprucelabs/test';
14
- import cloneDeep from 'lodash/cloneDeep.js';
15
- function removeProps(obj, keys) {
16
- if (obj instanceof Array) {
17
- obj.forEach(function (item, idx) {
18
- if (item instanceof AbstractSpruceError) {
19
- obj[idx] = item = { options: item.options };
20
- }
21
- removeProps(item, keys);
22
- });
23
- }
24
- else if (obj && typeof obj === 'object') {
25
- Object.getOwnPropertyNames(obj).forEach(function (key) {
26
- if (obj[key] instanceof AbstractSpruceError) {
27
- obj[key] = { options: obj[key].options };
28
- removeProps(obj[key], keys);
29
- }
30
- else if (keys.indexOf(key) !== -1) {
31
- delete obj[key];
32
- }
33
- else {
34
- removeProps(obj[key], keys);
35
- }
36
- });
37
- }
38
- }
39
- const errorAssertUtil = {
40
- assertError(error, expectedCode, expectedPartialOptions) {
41
- var _a, _b;
42
- const spruceErr = error;
43
- if (!(spruceErr instanceof AbstractSpruceError)) {
44
- if (spruceErr instanceof Error || spruceErr.message) {
45
- assertUtil.fail(`Did not receive a SpruceError, got:\n\nMessage: ${(_a = spruceErr.message) !== null && _a !== void 0 ? _a : '***missing***'}`, (_b = spruceErr.stack) !== null && _b !== void 0 ? _b : '');
46
- }
47
- else {
48
- assertUtil.fail(`Did not receive a SpruceError, got: \n\n${assertUtil.stringify(error)}`);
49
- }
50
- }
51
- if (spruceErr.options.code === expectedCode) {
52
- if (expectedPartialOptions) {
53
- assert.doesInclude(spruceErr.options, expectedPartialOptions);
54
- }
55
- }
56
- else {
57
- const _c = spruceErr.options, { code, friendlyMessage } = _c, options = __rest(_c, ["code", "friendlyMessage"]);
58
- assertUtil.fail(`Invalid error code. Expected:\n\n'${expectedCode}'\n\nbut got:\n\nCode: '${code}'\nMessage: '${friendlyMessage !== null && friendlyMessage !== void 0 ? friendlyMessage : spruceErr.message}'\nOptions:${assertUtil.stringify(options)}`, spruceErr.stack);
59
- }
60
- },
61
- stripFriendlyMessageFromOptions(options) {
62
- const clone = cloneDeep(options);
63
- removeProps(clone, ['friendlyMessage']);
64
- return clone;
65
- },
66
- };
1
+ import errorAssert from './errorAssert.js';
2
+ /**
3
+ * @deprecated errorAssertUtil -> errorAssert
4
+ */
5
+ const errorAssertUtil = errorAssert;
67
6
  export default errorAssertUtil;
package/build/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default as errorAssertUtil } from './utilities/errorAssert.utility';
1
+ export { default as errorAssert } from './utilities/errorAssert';
package/build/index.js CHANGED
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.errorAssertUtil = void 0;
7
- var errorAssert_utility_1 = require("./utilities/errorAssert.utility");
8
- Object.defineProperty(exports, "errorAssertUtil", { enumerable: true, get: function () { return __importDefault(errorAssert_utility_1).default; } });
6
+ exports.errorAssert = void 0;
7
+ var errorAssert_1 = require("./utilities/errorAssert");
8
+ Object.defineProperty(exports, "errorAssert", { enumerable: true, get: function () { return __importDefault(errorAssert_1).default; } });
@@ -0,0 +1,6 @@
1
+ import AbstractSpruceError from '@sprucelabs/error';
2
+ declare const errorAssert: {
3
+ assertError(error: Error | AbstractSpruceError<any>, expectedCode: string, expectedPartialOptions?: Record<string, any> | undefined): void;
4
+ stripFriendlyMessageFromOptions(options: Record<string, any> | Record<string, any>[]): Record<string, any> | Record<string, any>[];
5
+ };
6
+ export default errorAssert;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const error_1 = __importDefault(require("@sprucelabs/error"));
18
+ const test_1 = require("@sprucelabs/test");
19
+ const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
20
+ function removeProps(obj, keys) {
21
+ if (obj instanceof Array) {
22
+ obj.forEach(function (item, idx) {
23
+ if (item instanceof error_1.default) {
24
+ obj[idx] = item = { options: item.options };
25
+ }
26
+ removeProps(item, keys);
27
+ });
28
+ }
29
+ else if (obj && typeof obj === 'object') {
30
+ Object.getOwnPropertyNames(obj).forEach(function (key) {
31
+ if (obj[key] instanceof error_1.default) {
32
+ obj[key] = { options: obj[key].options };
33
+ removeProps(obj[key], keys);
34
+ }
35
+ else if (keys.indexOf(key) !== -1) {
36
+ delete obj[key];
37
+ }
38
+ else {
39
+ removeProps(obj[key], keys);
40
+ }
41
+ });
42
+ }
43
+ }
44
+ const errorAssert = {
45
+ assertError(error, expectedCode, expectedPartialOptions) {
46
+ var _a, _b;
47
+ const spruceErr = error;
48
+ if (!(spruceErr instanceof error_1.default)) {
49
+ if (spruceErr instanceof Error || spruceErr.message) {
50
+ test_1.assertUtil.fail(`Did not receive a SpruceError, got:\n\nMessage: ${(_a = spruceErr.message) !== null && _a !== void 0 ? _a : '***missing***'}`, (_b = spruceErr.stack) !== null && _b !== void 0 ? _b : '');
51
+ }
52
+ else {
53
+ test_1.assertUtil.fail(`Did not receive a SpruceError, got: \n\n${test_1.assertUtil.stringify(error)}`);
54
+ }
55
+ }
56
+ if (spruceErr.options.code === expectedCode) {
57
+ if (expectedPartialOptions) {
58
+ test_1.assert.doesInclude(spruceErr.options, expectedPartialOptions);
59
+ }
60
+ }
61
+ else {
62
+ const _c = spruceErr.options, { code, friendlyMessage } = _c, options = __rest(_c, ["code", "friendlyMessage"]);
63
+ test_1.assertUtil.fail(`Invalid error code. Expected:\n\n'${expectedCode}'\n\nbut got:\n\nCode: '${code}'\nMessage: '${friendlyMessage !== null && friendlyMessage !== void 0 ? friendlyMessage : spruceErr.message}'\nOptions:${test_1.assertUtil.stringify(options)}`, spruceErr.stack);
64
+ }
65
+ },
66
+ stripFriendlyMessageFromOptions(options) {
67
+ const clone = (0, cloneDeep_1.default)(options);
68
+ removeProps(clone, ['friendlyMessage']);
69
+ return clone;
70
+ },
71
+ };
72
+ exports.default = errorAssert;
@@ -1,6 +1,8 @@
1
- import AbstractSpruceError from '@sprucelabs/error';
1
+ /**
2
+ * @deprecated errorAssertUtil -> errorAssert
3
+ */
2
4
  declare const errorAssertUtil: {
3
- assertError(error: Error | AbstractSpruceError<any>, expectedCode: string, expectedPartialOptions?: Record<string, any> | undefined): void;
5
+ assertError(error: Error | import("@sprucelabs/error").default<any>, expectedCode: string, expectedPartialOptions?: Record<string, any> | undefined): void;
4
6
  stripFriendlyMessageFromOptions(options: Record<string, any> | Record<string, any>[]): Record<string, any> | Record<string, any>[];
5
7
  };
6
8
  export default errorAssertUtil;
@@ -1,72 +1,11 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
- const error_1 = __importDefault(require("@sprucelabs/error"));
18
- const test_1 = require("@sprucelabs/test");
19
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
20
- function removeProps(obj, keys) {
21
- if (obj instanceof Array) {
22
- obj.forEach(function (item, idx) {
23
- if (item instanceof error_1.default) {
24
- obj[idx] = item = { options: item.options };
25
- }
26
- removeProps(item, keys);
27
- });
28
- }
29
- else if (obj && typeof obj === 'object') {
30
- Object.getOwnPropertyNames(obj).forEach(function (key) {
31
- if (obj[key] instanceof error_1.default) {
32
- obj[key] = { options: obj[key].options };
33
- removeProps(obj[key], keys);
34
- }
35
- else if (keys.indexOf(key) !== -1) {
36
- delete obj[key];
37
- }
38
- else {
39
- removeProps(obj[key], keys);
40
- }
41
- });
42
- }
43
- }
44
- const errorAssertUtil = {
45
- assertError(error, expectedCode, expectedPartialOptions) {
46
- var _a, _b;
47
- const spruceErr = error;
48
- if (!(spruceErr instanceof error_1.default)) {
49
- if (spruceErr instanceof Error || spruceErr.message) {
50
- test_1.assertUtil.fail(`Did not receive a SpruceError, got:\n\nMessage: ${(_a = spruceErr.message) !== null && _a !== void 0 ? _a : '***missing***'}`, (_b = spruceErr.stack) !== null && _b !== void 0 ? _b : '');
51
- }
52
- else {
53
- test_1.assertUtil.fail(`Did not receive a SpruceError, got: \n\n${test_1.assertUtil.stringify(error)}`);
54
- }
55
- }
56
- if (spruceErr.options.code === expectedCode) {
57
- if (expectedPartialOptions) {
58
- test_1.assert.doesInclude(spruceErr.options, expectedPartialOptions);
59
- }
60
- }
61
- else {
62
- const _c = spruceErr.options, { code, friendlyMessage } = _c, options = __rest(_c, ["code", "friendlyMessage"]);
63
- test_1.assertUtil.fail(`Invalid error code. Expected:\n\n'${expectedCode}'\n\nbut got:\n\nCode: '${code}'\nMessage: '${friendlyMessage !== null && friendlyMessage !== void 0 ? friendlyMessage : spruceErr.message}'\nOptions:${test_1.assertUtil.stringify(options)}`, spruceErr.stack);
64
- }
65
- },
66
- stripFriendlyMessageFromOptions(options) {
67
- const clone = (0, cloneDeep_1.default)(options);
68
- removeProps(clone, ['friendlyMessage']);
69
- return clone;
70
- },
71
- };
6
+ const errorAssert_1 = __importDefault(require("./errorAssert"));
7
+ /**
8
+ * @deprecated errorAssertUtil -> errorAssert
9
+ */
10
+ const errorAssertUtil = errorAssert_1.default;
72
11
  exports.default = errorAssertUtil;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.0.390",
6
+ "version": "3.0.394",
7
7
  "files": [
8
8
  "build"
9
9
  ],
@@ -63,18 +63,18 @@
63
63
  "watch.tsc": "tsc -w"
64
64
  },
65
65
  "dependencies": {
66
- "@sprucelabs/error": "^5.0.383",
67
- "@sprucelabs/test": "^7.7.276",
66
+ "@sprucelabs/error": "^5.0.386",
67
+ "@sprucelabs/test": "^7.7.277",
68
68
  "lodash": "^4.17.21"
69
69
  },
70
70
  "devDependencies": {
71
- "@sprucelabs/esm-postbuild": "^1.0.331",
71
+ "@sprucelabs/esm-postbuild": "^1.0.333",
72
72
  "@sprucelabs/semantic-release": "^4.0.8",
73
73
  "@types/lodash": "^4.14.178",
74
74
  "@types/node": "^17.0.13",
75
75
  "chokidar-cli": "^3.0.0",
76
76
  "conventional-changelog-sprucelabs": "^1.1.2",
77
- "eslint": "^8.7.0",
77
+ "eslint": "^8.8.0",
78
78
  "eslint-config-spruce": "^10.11.2",
79
79
  "jest": "^27.4.7",
80
80
  "jest-circus": "^27.4.6",