kizu 3.7.7 → 3.8.0
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/dist/assertions/index.d.ts +4 -2
- package/dist/assertions/index.js +7 -6
- package/dist/assertions/{errorsEquivalent.d.ts → isError.d.ts} +1 -1
- package/dist/assertions/{errorsEquivalent.js → isError.js} +3 -3
- package/dist/assertions/throws.d.ts +1 -1
- package/dist/assertions/throws.js +36 -10
- package/dist/test.d.ts +1 -3
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Assertion } from '../test';
|
|
2
|
-
export
|
|
2
|
+
export type AssertionAPI = {
|
|
3
3
|
pass: (description?: string) => void;
|
|
4
4
|
fail: (description?: string) => void;
|
|
5
5
|
isTrue: (condition: boolean, description?: string) => void;
|
|
6
6
|
isFalse: (condition: boolean, description?: string) => void;
|
|
7
7
|
equal: (actual: any, expected: any, description?: string) => void;
|
|
8
|
+
isError: (actual: any, expected: any, description?: string) => void;
|
|
8
9
|
errorsEquivalent: (actual: any, expected: any, description?: string) => void;
|
|
9
|
-
throws: (experiment: () => any, expectedErr: Error | RegExp, description?: string) => void
|
|
10
|
+
throws: (experiment: () => any, expectedErr: Error | RegExp, description?: string) => Promise<void>;
|
|
10
11
|
};
|
|
12
|
+
export declare function createAssertionPredicates(assertions: Assertion[]): AssertionAPI;
|
package/dist/assertions/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createAssertionPredicates = createAssertionPredicates;
|
|
4
|
-
const
|
|
4
|
+
const isError_1 = require("./isError");
|
|
5
5
|
const equal_1 = require("./equal");
|
|
6
6
|
const throws_1 = require("./throws");
|
|
7
7
|
const isTrue_1 = require("./isTrue");
|
|
@@ -10,12 +10,13 @@ const fail_1 = require("./fail");
|
|
|
10
10
|
const pass_1 = require("./pass");
|
|
11
11
|
function createAssertionPredicates(assertions) {
|
|
12
12
|
return {
|
|
13
|
-
pass: (description) => (
|
|
14
|
-
fail: (description) => (
|
|
15
|
-
isTrue: (condition, description) => (
|
|
16
|
-
isFalse: (condition, description) => (
|
|
13
|
+
pass: (description) => (0, pass_1.pass)(assertions, description),
|
|
14
|
+
fail: (description) => (0, fail_1.fail)(assertions, description),
|
|
15
|
+
isTrue: (condition, description) => (0, isTrue_1.isTrue)(assertions, condition, description),
|
|
16
|
+
isFalse: (condition, description) => (0, isFalse_1.isFalse)(assertions, condition, description),
|
|
17
17
|
equal: (actual, expected, description) => ((0, equal_1.equal)(assertions, actual, expected, description)),
|
|
18
|
-
|
|
18
|
+
isError: (actual, expected, description) => ((0, isError_1.isError)(assertions, actual, expected, description)),
|
|
19
|
+
errorsEquivalent: (actual, expected, description) => ((0, isError_1.isError)(assertions, actual, expected, description)), // deprecated
|
|
19
20
|
throws: (experiment, expectedErr, description) => ((0, throws_1.throws)(assertions, experiment, expectedErr, description)),
|
|
20
21
|
};
|
|
21
22
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Assertion } from '../test';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function isError(assertions: Assertion[], actualErr: Error, expectedErr: Error | RegExp, description?: string): void;
|
|
3
3
|
export declare function createDiagnosticRegexMismatch(actualErrMsg: string, expectedRegEx: RegExp): string;
|
|
@@ -3,14 +3,14 @@ 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.
|
|
6
|
+
exports.isError = isError;
|
|
7
7
|
exports.createDiagnosticRegexMismatch = createDiagnosticRegexMismatch;
|
|
8
8
|
const serialize_error_1 = require("serialize-error");
|
|
9
9
|
const equal_1 = require("./equal");
|
|
10
10
|
const pass_1 = require("./pass");
|
|
11
11
|
const AssertionError_1 = require("./AssertionError");
|
|
12
12
|
const kleur_1 = __importDefault(require("kleur"));
|
|
13
|
-
function
|
|
13
|
+
function isError(assertions, actualErr, expectedErr, description) {
|
|
14
14
|
if (!(actualErr instanceof Error))
|
|
15
15
|
throw new Error('actualErr is not an instance of Error');
|
|
16
16
|
if (!(expectedErr instanceof Error) && !(expectedErr instanceof RegExp))
|
|
@@ -46,4 +46,4 @@ function createDiagnosticRegexMismatch(actualErrMsg, expectedRegEx) {
|
|
|
46
46
|
const expected = `\n\n${kleur_1.default.grey().bold('Expected RegEx:')}\n\n${expectedRegEx}`;
|
|
47
47
|
return `${actual}${expected}\n\n`;
|
|
48
48
|
}
|
|
49
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=isError.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Assertion } from '../test';
|
|
2
|
-
export declare function throws(assertions: Assertion[], experiment: () => any, expectedErr: Error | RegExp, description?: string): void
|
|
2
|
+
export declare function throws(assertions: Assertion[], experiment: () => any, expectedErr: Error | RegExp, description?: string): Promise<void>;
|
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.throws = throws;
|
|
4
|
-
const
|
|
5
|
-
const errorsEquivalent_1 = require("./errorsEquivalent");
|
|
13
|
+
const isError_1 = require("./isError");
|
|
6
14
|
function throws(assertions, experiment, expectedErr, description) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
if (typeof experiment !== 'function')
|
|
17
|
+
throw new Error('experiment must be a function');
|
|
18
|
+
if (!(expectedErr instanceof Error) && !(expectedErr instanceof RegExp))
|
|
19
|
+
throw new Error('expectedErr is not an instance of Error or a RegExp');
|
|
20
|
+
let actualErr;
|
|
21
|
+
try {
|
|
22
|
+
const result = experiment();
|
|
23
|
+
// Check if the result is a Promise
|
|
24
|
+
if (result && typeof result.then === 'function') {
|
|
25
|
+
// Handle async function - wait for the promise to resolve or reject
|
|
26
|
+
yield result;
|
|
27
|
+
// If we get here, the promise resolved without throwing
|
|
28
|
+
throw new Error('experiment did not throw an error');
|
|
29
|
+
}
|
|
30
|
+
// If we get here, the sync function completed without throwing
|
|
31
|
+
throw new Error('experiment did not throw an error');
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
actualErr = e;
|
|
35
|
+
}
|
|
36
|
+
if (!actualErr) {
|
|
37
|
+
throw new Error('experiment did not throw an error');
|
|
38
|
+
}
|
|
39
|
+
(0, isError_1.isError)(assertions, actualErr, expectedErr, description || 'throws()');
|
|
40
|
+
});
|
|
15
41
|
}
|
|
16
42
|
//# sourceMappingURL=throws.js.map
|
package/dist/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AssertionAPI } from './assertions';
|
|
2
2
|
import { ErrorObject } from 'serialize-error';
|
|
3
3
|
export type TestResults = {
|
|
4
4
|
description: string;
|
|
@@ -11,6 +11,4 @@ export type Assertion = {
|
|
|
11
11
|
diagnostic?: string;
|
|
12
12
|
stack?: string;
|
|
13
13
|
};
|
|
14
|
-
type AssertionAPI = ReturnType<typeof createAssertionPredicates>;
|
|
15
14
|
export declare function test(description: string, experiment: (assert: AssertionAPI) => void): Promise<void>;
|
|
16
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kizu",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "An easy-to-use, fast, and defensive Typescript/Javascript test runner designed to help you to write simple, readable, and maintainable tests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|