@plugjs/expect5 0.4.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/README.md +7 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.mjs +96 -0
- package/dist/cli.mjs.map +6 -0
- package/dist/execution/executable.cjs +299 -0
- package/dist/execution/executable.cjs.map +6 -0
- package/dist/execution/executable.d.ts +87 -0
- package/dist/execution/executable.mjs +260 -0
- package/dist/execution/executable.mjs.map +6 -0
- package/dist/execution/executor.cjs +125 -0
- package/dist/execution/executor.cjs.map +6 -0
- package/dist/execution/executor.d.ts +35 -0
- package/dist/execution/executor.mjs +90 -0
- package/dist/execution/executor.mjs.map +6 -0
- package/dist/execution/setup.cjs +127 -0
- package/dist/execution/setup.cjs.map +6 -0
- package/dist/execution/setup.d.ts +31 -0
- package/dist/execution/setup.mjs +87 -0
- package/dist/execution/setup.mjs.map +6 -0
- package/dist/expectation/basic.cjs +216 -0
- package/dist/expectation/basic.cjs.map +6 -0
- package/dist/expectation/basic.d.ts +47 -0
- package/dist/expectation/basic.mjs +177 -0
- package/dist/expectation/basic.mjs.map +6 -0
- package/dist/expectation/diff.cjs +253 -0
- package/dist/expectation/diff.cjs.map +6 -0
- package/dist/expectation/diff.d.ts +27 -0
- package/dist/expectation/diff.mjs +228 -0
- package/dist/expectation/diff.mjs.map +6 -0
- package/dist/expectation/expect.cjs +211 -0
- package/dist/expectation/expect.cjs.map +6 -0
- package/dist/expectation/expect.d.ts +140 -0
- package/dist/expectation/expect.mjs +219 -0
- package/dist/expectation/expect.mjs.map +6 -0
- package/dist/expectation/include.cjs +187 -0
- package/dist/expectation/include.cjs.map +6 -0
- package/dist/expectation/include.d.ts +10 -0
- package/dist/expectation/include.mjs +158 -0
- package/dist/expectation/include.mjs.map +6 -0
- package/dist/expectation/print.cjs +281 -0
- package/dist/expectation/print.cjs.map +6 -0
- package/dist/expectation/print.d.ts +4 -0
- package/dist/expectation/print.mjs +256 -0
- package/dist/expectation/print.mjs.map +6 -0
- package/dist/expectation/throwing.cjs +58 -0
- package/dist/expectation/throwing.cjs.map +6 -0
- package/dist/expectation/throwing.d.ts +8 -0
- package/dist/expectation/throwing.mjs +32 -0
- package/dist/expectation/throwing.mjs.map +6 -0
- package/dist/expectation/types.cjs +212 -0
- package/dist/expectation/types.cjs.map +6 -0
- package/dist/expectation/types.d.ts +57 -0
- package/dist/expectation/types.mjs +178 -0
- package/dist/expectation/types.mjs.map +6 -0
- package/dist/expectation/void.cjs +111 -0
- package/dist/expectation/void.cjs.map +6 -0
- package/dist/expectation/void.d.ts +39 -0
- package/dist/expectation/void.mjs +77 -0
- package/dist/expectation/void.mjs.map +6 -0
- package/dist/globals.cjs +2 -0
- package/dist/globals.cjs.map +6 -0
- package/dist/globals.d.ts +23 -0
- package/dist/globals.mjs +1 -0
- package/dist/globals.mjs.map +6 -0
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +6 -0
- package/dist/test.cjs +229 -0
- package/dist/test.cjs.map +6 -0
- package/dist/test.d.ts +9 -0
- package/dist/test.mjs +194 -0
- package/dist/test.mjs.map +6 -0
- package/package.json +57 -0
- package/src/cli.mts +122 -0
- package/src/execution/executable.ts +364 -0
- package/src/execution/executor.ts +146 -0
- package/src/execution/setup.ts +108 -0
- package/src/expectation/basic.ts +209 -0
- package/src/expectation/diff.ts +445 -0
- package/src/expectation/expect.ts +401 -0
- package/src/expectation/include.ts +184 -0
- package/src/expectation/print.ts +386 -0
- package/src/expectation/throwing.ts +45 -0
- package/src/expectation/types.ts +263 -0
- package/src/expectation/void.ts +80 -0
- package/src/globals.ts +30 -0
- package/src/index.ts +54 -0
- package/src/test.ts +239 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Call } from './executable';
|
|
2
|
+
export type SuiteSetup = (name: string, call: Call, timeout?: number) => void;
|
|
3
|
+
export type SuiteFunction = SuiteSetup & {
|
|
4
|
+
only: SuiteSetup;
|
|
5
|
+
skip: SuiteSetup;
|
|
6
|
+
};
|
|
7
|
+
export declare const describe: SuiteFunction;
|
|
8
|
+
export declare const fdescribe: SuiteSetup;
|
|
9
|
+
export declare const xdescribe: SuiteSetup;
|
|
10
|
+
export type SpecSetup = (name: string, call: Call, timeout?: number) => void;
|
|
11
|
+
export type SpecFunction = SpecSetup & {
|
|
12
|
+
only: SpecSetup;
|
|
13
|
+
skip: SpecSetup;
|
|
14
|
+
};
|
|
15
|
+
export declare const it: SpecFunction;
|
|
16
|
+
export declare const fit: SpecSetup;
|
|
17
|
+
export declare const xit: SpecSetup;
|
|
18
|
+
export type HookSetup = (call: Call, timeout?: number) => void;
|
|
19
|
+
export type HookFunction = HookSetup & {
|
|
20
|
+
skip: HookSetup;
|
|
21
|
+
};
|
|
22
|
+
export declare const beforeAll: HookFunction;
|
|
23
|
+
export declare const xbeforeAll: HookSetup;
|
|
24
|
+
export declare const beforeEach: HookFunction;
|
|
25
|
+
export declare const xbeforeEach: HookSetup;
|
|
26
|
+
export declare const afterAll: HookFunction;
|
|
27
|
+
export declare const xafterAll: HookSetup;
|
|
28
|
+
export declare const afterEach: HookFunction;
|
|
29
|
+
export declare const xafterEach: HookSetup;
|
|
30
|
+
export declare const before: HookSetup;
|
|
31
|
+
export declare const after: HookSetup;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// execution/setup.ts
|
|
2
|
+
import { getCurrentSuite, Suite, Spec, Hook } from "./executable.mjs";
|
|
3
|
+
var describe = (name, call, timeout) => {
|
|
4
|
+
const parent = getCurrentSuite();
|
|
5
|
+
parent.addSuite(new Suite(parent, name, call, timeout));
|
|
6
|
+
};
|
|
7
|
+
var fdescribe = (name, call, timeout) => {
|
|
8
|
+
const parent = getCurrentSuite();
|
|
9
|
+
parent.addSuite(new Suite(parent, name, call, timeout, "only"));
|
|
10
|
+
};
|
|
11
|
+
var xdescribe = (name, call, timeout) => {
|
|
12
|
+
const parent = getCurrentSuite();
|
|
13
|
+
parent.addSuite(new Suite(parent, name, call, timeout, "skip"));
|
|
14
|
+
};
|
|
15
|
+
describe.skip = xdescribe;
|
|
16
|
+
describe.only = fdescribe;
|
|
17
|
+
var it = (name, call, timeout) => {
|
|
18
|
+
const parent = getCurrentSuite();
|
|
19
|
+
parent.addSpec(new Spec(parent, name, call, timeout));
|
|
20
|
+
};
|
|
21
|
+
var fit = (name, call, timeout) => {
|
|
22
|
+
const parent = getCurrentSuite();
|
|
23
|
+
parent.addSpec(new Spec(parent, name, call, timeout, "only"));
|
|
24
|
+
};
|
|
25
|
+
var xit = (name, call, timeout) => {
|
|
26
|
+
const parent = getCurrentSuite();
|
|
27
|
+
parent.addSpec(new Spec(parent, name, call, timeout, "skip"));
|
|
28
|
+
};
|
|
29
|
+
it.skip = xit;
|
|
30
|
+
it.only = fit;
|
|
31
|
+
var beforeAll = (call, timeout) => {
|
|
32
|
+
const parent = getCurrentSuite();
|
|
33
|
+
parent.addBeforeAllHook(new Hook(parent, "beforeAll", call, timeout));
|
|
34
|
+
};
|
|
35
|
+
var xbeforeAll = (call, timeout) => {
|
|
36
|
+
const parent = getCurrentSuite();
|
|
37
|
+
parent.addBeforeAllHook(new Hook(parent, "beforeAll", call, timeout, "skip"));
|
|
38
|
+
};
|
|
39
|
+
var beforeEach = (call, timeout) => {
|
|
40
|
+
const parent = getCurrentSuite();
|
|
41
|
+
parent.addBeforeEachHook(new Hook(parent, "beforeEach", call, timeout));
|
|
42
|
+
};
|
|
43
|
+
var xbeforeEach = (call, timeout) => {
|
|
44
|
+
const parent = getCurrentSuite();
|
|
45
|
+
parent.addBeforeEachHook(new Hook(parent, "beforeEach", call, timeout, "skip"));
|
|
46
|
+
};
|
|
47
|
+
var afterAll = (call, timeout) => {
|
|
48
|
+
const parent = getCurrentSuite();
|
|
49
|
+
parent.addAfterAllHook(new Hook(parent, "afterAll", call, timeout));
|
|
50
|
+
};
|
|
51
|
+
var xafterAll = (call, timeout) => {
|
|
52
|
+
const parent = getCurrentSuite();
|
|
53
|
+
parent.addAfterAllHook(new Hook(parent, "afterAll", call, timeout, "skip"));
|
|
54
|
+
};
|
|
55
|
+
var afterEach = (call, timeout) => {
|
|
56
|
+
const parent = getCurrentSuite();
|
|
57
|
+
parent.addAfterEachHook(new Hook(parent, "afterEach", call, timeout));
|
|
58
|
+
};
|
|
59
|
+
var xafterEach = (call, timeout) => {
|
|
60
|
+
const parent = getCurrentSuite();
|
|
61
|
+
parent.addAfterEachHook(new Hook(parent, "afterEach", call, timeout, "skip"));
|
|
62
|
+
};
|
|
63
|
+
beforeAll.skip = xbeforeAll;
|
|
64
|
+
beforeEach.skip = xbeforeEach;
|
|
65
|
+
afterAll.skip = xafterAll;
|
|
66
|
+
afterEach.skip = xafterEach;
|
|
67
|
+
var before = beforeAll;
|
|
68
|
+
var after = afterAll;
|
|
69
|
+
export {
|
|
70
|
+
after,
|
|
71
|
+
afterAll,
|
|
72
|
+
afterEach,
|
|
73
|
+
before,
|
|
74
|
+
beforeAll,
|
|
75
|
+
beforeEach,
|
|
76
|
+
describe,
|
|
77
|
+
fdescribe,
|
|
78
|
+
fit,
|
|
79
|
+
it,
|
|
80
|
+
xafterAll,
|
|
81
|
+
xafterEach,
|
|
82
|
+
xbeforeAll,
|
|
83
|
+
xbeforeEach,
|
|
84
|
+
xdescribe,
|
|
85
|
+
xit
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=setup.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/execution/setup.ts"],
|
|
4
|
+
"mappings": ";AAAA,SAAS,iBAAiB,OAAO,MAAM,YAAY;AAU5C,IAAM,WAA0B,CAAC,MAAc,MAAY,YAA2B;AAC3F,QAAM,SAAS,gBAAgB;AAC/B,SAAO,SAAS,IAAI,MAAM,QAAQ,MAAM,MAAM,OAAO,CAAC;AACxD;AAEO,IAAM,YA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,YAA2B;AAC5E,QAAM,SAAS,gBAAgB;AAC/B,SAAO,kBAAkB,IAAI,KAAK,QAAQ,cAAc,MAAM,SAAS,MAAM,CAAC;AAChF;AAEO,IAAM,WAAyB,CAAC,MAAY,YAA2B;AAC5E,QAAM,SAAS,gBAAgB;AAC/B,SAAO,gBAAgB,IAAI,KAAK,QAAQ,YAAY,MAAM,OAAO,CAAC;AACpE;AAEO,IAAM,YAAuB,CAAC,MAAY,YAA2B;AAC1E,QAAM,SAAS,gBAAgB;AAC/B,SAAO,gBAAgB,IAAI,KAAK,QAAQ,YAAY,MAAM,SAAS,MAAM,CAAC;AAC5E;AAEO,IAAM,YAA0B,CAAC,MAAY,YAA2B;AAC7E,QAAM,SAAS,gBAAgB;AAC/B,SAAO,iBAAiB,IAAI,KAAK,QAAQ,aAAa,MAAM,OAAO,CAAC;AACtE;AAEO,IAAM,aAAwB,CAAC,MAAY,YAA2B;AAC3E,QAAM,SAAS,gBAAgB;AAC/B,SAAO,iBAAiB,IAAI,KAAK,QAAQ,aAAa,MAAM,SAAS,MAAM,CAAC;AAC9E;AAEA,UAAU,OAAO;AACjB,WAAW,OAAO;AAClB,SAAS,OAAO;AAChB,UAAU,OAAO;AAEV,IAAM,SAAoB;AAC1B,IAAM,QAAmB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// expectation/basic.ts
|
|
21
|
+
var basic_exports = {};
|
|
22
|
+
__export(basic_exports, {
|
|
23
|
+
ToBeA: () => ToBeA,
|
|
24
|
+
ToBeCloseTo: () => ToBeCloseTo,
|
|
25
|
+
ToBeError: () => ToBeError,
|
|
26
|
+
ToBeGreaterThan: () => ToBeGreaterThan,
|
|
27
|
+
ToBeGreaterThanOrEqual: () => ToBeGreaterThanOrEqual,
|
|
28
|
+
ToBeInstanceOf: () => ToBeInstanceOf,
|
|
29
|
+
ToBeLessThan: () => ToBeLessThan,
|
|
30
|
+
ToBeLessThanOrEqual: () => ToBeLessThanOrEqual,
|
|
31
|
+
ToBeWithinRange: () => ToBeWithinRange,
|
|
32
|
+
ToEqual: () => ToEqual,
|
|
33
|
+
ToHaveLength: () => ToHaveLength,
|
|
34
|
+
ToHaveProperty: () => ToHaveProperty,
|
|
35
|
+
ToHaveSize: () => ToHaveSize,
|
|
36
|
+
ToMatch: () => ToMatch,
|
|
37
|
+
ToStrictlyEqual: () => ToStrictlyEqual
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(basic_exports);
|
|
40
|
+
var import_diff = require("./diff.cjs");
|
|
41
|
+
var import_types = require("./types.cjs");
|
|
42
|
+
var ToBeA = class {
|
|
43
|
+
expect(context, negative, type) {
|
|
44
|
+
const match = (0, import_types.isType)(context, type);
|
|
45
|
+
if (match !== negative)
|
|
46
|
+
return;
|
|
47
|
+
throw new import_types.ExpectationError(context, negative, `to be ${(0, import_types.prefixType)(type)}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var ToBeCloseTo = class {
|
|
51
|
+
expect(context, negative, ...[value, delta]) {
|
|
52
|
+
const min = value - delta;
|
|
53
|
+
const max = value + delta;
|
|
54
|
+
context.negated(negative).toBeWithinRange(min, max);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var ToBeError = class {
|
|
58
|
+
expect(context, negative, ...args) {
|
|
59
|
+
const [constructor, message] = typeof args[0] === "function" ? [args[0], args[1]] : [Error, args[0]];
|
|
60
|
+
context.negated(negative).toBeInstanceOf(constructor);
|
|
61
|
+
if (negative || message === void 0)
|
|
62
|
+
return;
|
|
63
|
+
context.toHaveProperty("message", (assert) => {
|
|
64
|
+
(0, import_types.assertType)(assert, "string");
|
|
65
|
+
if (typeof message === "string")
|
|
66
|
+
assert.toStrictlyEqual(message);
|
|
67
|
+
else
|
|
68
|
+
assert.toMatch(message);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var ToBeGreaterThan = class {
|
|
73
|
+
expect(context, negative, value) {
|
|
74
|
+
(0, import_types.assertType)(context, typeof value);
|
|
75
|
+
if (context.value > value !== negative)
|
|
76
|
+
return;
|
|
77
|
+
throw new import_types.ExpectationError(context, negative, `to be greater than ${(0, import_types.stringifyValue)(value)}`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var ToBeGreaterThanOrEqual = class {
|
|
81
|
+
expect(context, negative, value) {
|
|
82
|
+
(0, import_types.assertType)(context, typeof value);
|
|
83
|
+
if (context.value >= value !== negative)
|
|
84
|
+
return;
|
|
85
|
+
throw new import_types.ExpectationError(context, negative, `to be greater than or equal to ${(0, import_types.stringifyValue)(value)}`);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var ToBeInstanceOf = class {
|
|
89
|
+
expect(context, negative, value) {
|
|
90
|
+
const match = context.value instanceof value;
|
|
91
|
+
if (match !== negative)
|
|
92
|
+
return;
|
|
93
|
+
throw new import_types.ExpectationError(context, negative, `to be an instance of ${(0, import_types.stringifyConstructor)(value)}`);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var ToBeLessThan = class {
|
|
97
|
+
expect(context, negative, value) {
|
|
98
|
+
(0, import_types.assertType)(context, typeof value);
|
|
99
|
+
if (context.value < value !== negative)
|
|
100
|
+
return;
|
|
101
|
+
throw new import_types.ExpectationError(context, negative, `to be less than ${(0, import_types.stringifyValue)(value)}`);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var ToBeLessThanOrEqual = class {
|
|
105
|
+
expect(context, negative, value) {
|
|
106
|
+
(0, import_types.assertType)(context, typeof value);
|
|
107
|
+
if (context.value <= value !== negative)
|
|
108
|
+
return;
|
|
109
|
+
throw new import_types.ExpectationError(context, negative, `to be less than or equal to ${(0, import_types.stringifyValue)(value)}`);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var ToBeWithinRange = class {
|
|
113
|
+
expect(context, negative, ...[min, max]) {
|
|
114
|
+
if (max < min) {
|
|
115
|
+
const num = max;
|
|
116
|
+
max = min;
|
|
117
|
+
min = num;
|
|
118
|
+
}
|
|
119
|
+
(0, import_types.assertType)(context, typeof min);
|
|
120
|
+
if ((context.value >= min && context.value <= max) !== negative)
|
|
121
|
+
return;
|
|
122
|
+
throw new import_types.ExpectationError(context, negative, `to be within ${(0, import_types.stringifyValue)(min)}...${(0, import_types.stringifyValue)(max)}`);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var ToEqual = class {
|
|
126
|
+
expect(context, negative, expected) {
|
|
127
|
+
const result = (0, import_diff.diff)(context.value, expected);
|
|
128
|
+
if (result.diff === negative)
|
|
129
|
+
return;
|
|
130
|
+
throw new import_types.ExpectationError(context, negative, `to equal ${(0, import_types.stringifyValue)(expected)}`, result);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var ToHaveLength = class {
|
|
134
|
+
expect(context, negative, length) {
|
|
135
|
+
context.toBeDefined();
|
|
136
|
+
const actualLength = context.value.length;
|
|
137
|
+
if (typeof actualLength !== "number") {
|
|
138
|
+
throw new import_types.ExpectationError(context, false, 'to have a numeric "length" property');
|
|
139
|
+
}
|
|
140
|
+
if (actualLength === length === negative) {
|
|
141
|
+
throw new import_types.ExpectationError(context, negative, `to have length ${(0, import_types.stringifyValue)(length)}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var ToHaveProperty = class {
|
|
146
|
+
expect(context, negative, prop, assert) {
|
|
147
|
+
context.toBeDefined();
|
|
148
|
+
const match = context.value[prop] !== void 0;
|
|
149
|
+
if (match === negative) {
|
|
150
|
+
throw new import_types.ExpectationError(context, negative, `to have property "${String(prop)}"`);
|
|
151
|
+
} else if (match && assert) {
|
|
152
|
+
try {
|
|
153
|
+
assert(context.forProperty(prop));
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (error instanceof import_types.ExpectationError && error.diff) {
|
|
156
|
+
error.diff = {
|
|
157
|
+
diff: true,
|
|
158
|
+
value: context.value,
|
|
159
|
+
props: { [prop]: error.diff }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var ToHaveSize = class {
|
|
168
|
+
expect(context, negative, size) {
|
|
169
|
+
context.toBeDefined();
|
|
170
|
+
const actualSize = context.value.size;
|
|
171
|
+
if (typeof actualSize !== "number") {
|
|
172
|
+
throw new import_types.ExpectationError(context, false, 'to have a numeric "size" property');
|
|
173
|
+
}
|
|
174
|
+
if (actualSize === size === negative) {
|
|
175
|
+
throw new import_types.ExpectationError(context, negative, `to have size ${(0, import_types.stringifyValue)(size)}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var ToMatch = class {
|
|
180
|
+
expect(context, negative, expr) {
|
|
181
|
+
(0, import_types.assertType)(context, "string");
|
|
182
|
+
const match = !!context.value.match(expr);
|
|
183
|
+
if (match !== negative)
|
|
184
|
+
return;
|
|
185
|
+
throw new import_types.ExpectationError(context, negative, `to match ${(0, import_types.stringifyValue)(expr)}`);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var ToStrictlyEqual = class {
|
|
189
|
+
expect(context, negative, expected) {
|
|
190
|
+
const value = context.value;
|
|
191
|
+
const match = value === expected;
|
|
192
|
+
if (match !== negative)
|
|
193
|
+
return;
|
|
194
|
+
const diff2 = negative ? void 0 : { diff: true, value, expected };
|
|
195
|
+
throw new import_types.ExpectationError(context, negative, `to strictly equal ${(0, import_types.stringifyValue)(expected)}`, diff2);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
199
|
+
0 && (module.exports = {
|
|
200
|
+
ToBeA,
|
|
201
|
+
ToBeCloseTo,
|
|
202
|
+
ToBeError,
|
|
203
|
+
ToBeGreaterThan,
|
|
204
|
+
ToBeGreaterThanOrEqual,
|
|
205
|
+
ToBeInstanceOf,
|
|
206
|
+
ToBeLessThan,
|
|
207
|
+
ToBeLessThanOrEqual,
|
|
208
|
+
ToBeWithinRange,
|
|
209
|
+
ToEqual,
|
|
210
|
+
ToHaveLength,
|
|
211
|
+
ToHaveProperty,
|
|
212
|
+
ToHaveSize,
|
|
213
|
+
ToMatch,
|
|
214
|
+
ToStrictlyEqual
|
|
215
|
+
});
|
|
216
|
+
//# sourceMappingURL=basic.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/expectation/basic.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,mBAAuG;AAKhG,IAAM,QAAN,MAAmC;AAAA,EACxC,OAAO,SAAuB,U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A,IACtF;AAAA,EACF;AACF;AAEO,IAAM,UAAN,MAAqC;AAAA,EAC1C,OACI,SACA,UACA,MACI;AACN,iCAAW,SAAS,QAAQ;AAE5B,UAAM,QAAQ,CAAC,CAAE,QAAQ,MAAM,MAAM,IAAuB;AAC5D,QAAI,UAAU;AAAU;AAExB,UAAM,IAAI,8BAAiB,SAAS,UAAU,gBAAY,6BAAe,IAAI,GAAG;AAAA,EAClF;AACF;AAEO,IAAM,kBAAN,MAA6C;AAAA,EAClD,OAAO,SAAuB,UAAmB,UAAqB;AACpE,UAAM,QAAQ,QAAQ;AACtB,UAAM,QAAQ,UAAU;AACxB,QAAI,UAAU;AAAU;AAExB,UAAMA,QAAO,WAAW,SAAY,EAAE,MAAM,MAAM,OAAO,SAAS;AAClE,UAAM,IAAI,8BAAiB,SAAS,UAAU,yBAAqB,6BAAe,QAAQ,KAAKA,KAAI;AAAA,EACrG;AACF;",
|
|
5
|
+
"names": ["diff"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Constructor, TypeName, StringMatcher } from './types';
|
|
2
|
+
import type { Expectation, Expectations } from './expect';
|
|
3
|
+
export declare class ToBeA implements Expectation {
|
|
4
|
+
expect(context: Expectations, negative: boolean, type: TypeName): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class ToBeCloseTo implements Expectation {
|
|
7
|
+
expect(context: Expectations, negative: boolean, ...[value, delta]: [value: number, delta: number] | [value: bigint, delta: bigint]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class ToBeError implements Expectation {
|
|
10
|
+
expect(context: Expectations, negative: boolean, ...args: [] | [message: StringMatcher] | [constructor: Constructor<Error>] | [constructor: Constructor<Error>, message: StringMatcher]): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class ToBeGreaterThan implements Expectation {
|
|
13
|
+
expect(context: Expectations, negative: boolean, value: number | bigint): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class ToBeGreaterThanOrEqual implements Expectation {
|
|
16
|
+
expect(context: Expectations, negative: boolean, value: number | bigint): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class ToBeInstanceOf implements Expectation {
|
|
19
|
+
expect(context: Expectations, negative: boolean, value: Constructor): void;
|
|
20
|
+
}
|
|
21
|
+
export declare class ToBeLessThan implements Expectation {
|
|
22
|
+
expect(context: Expectations, negative: boolean, value: number | bigint): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class ToBeLessThanOrEqual implements Expectation {
|
|
25
|
+
expect(context: Expectations, negative: boolean, value: number | bigint): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class ToBeWithinRange implements Expectation {
|
|
28
|
+
expect(context: Expectations, negative: boolean, ...[min, max]: [min: number, max: number] | [min: bigint, max: bigint]): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class ToEqual implements Expectation {
|
|
31
|
+
expect(context: Expectations, negative: boolean, expected: any): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class ToHaveLength implements Expectation {
|
|
34
|
+
expect(context: Expectations, negative: boolean, length: number): void;
|
|
35
|
+
}
|
|
36
|
+
export declare class ToHaveProperty implements Expectation {
|
|
37
|
+
expect(context: Expectations, negative: boolean, prop: string | number | symbol, assert?: (propertyExpectations: Expectations) => void): void;
|
|
38
|
+
}
|
|
39
|
+
export declare class ToHaveSize implements Expectation {
|
|
40
|
+
expect(context: Expectations, negative: boolean, size: number): void;
|
|
41
|
+
}
|
|
42
|
+
export declare class ToMatch implements Expectation {
|
|
43
|
+
expect(context: Expectations, negative: boolean, expr: StringMatcher): void;
|
|
44
|
+
}
|
|
45
|
+
export declare class ToStrictlyEqual implements Expectation {
|
|
46
|
+
expect(context: Expectations, negative: boolean, expected: any): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// expectation/basic.ts
|
|
2
|
+
import { diff } from "./diff.mjs";
|
|
3
|
+
import { assertType, ExpectationError, isType, prefixType, stringifyConstructor, stringifyValue } from "./types.mjs";
|
|
4
|
+
var ToBeA = class {
|
|
5
|
+
expect(context, negative, type) {
|
|
6
|
+
const match = isType(context, type);
|
|
7
|
+
if (match !== negative)
|
|
8
|
+
return;
|
|
9
|
+
throw new ExpectationError(context, negative, `to be ${prefixType(type)}`);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var ToBeCloseTo = class {
|
|
13
|
+
expect(context, negative, ...[value, delta]) {
|
|
14
|
+
const min = value - delta;
|
|
15
|
+
const max = value + delta;
|
|
16
|
+
context.negated(negative).toBeWithinRange(min, max);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var ToBeError = class {
|
|
20
|
+
expect(context, negative, ...args) {
|
|
21
|
+
const [constructor, message] = typeof args[0] === "function" ? [args[0], args[1]] : [Error, args[0]];
|
|
22
|
+
context.negated(negative).toBeInstanceOf(constructor);
|
|
23
|
+
if (negative || message === void 0)
|
|
24
|
+
return;
|
|
25
|
+
context.toHaveProperty("message", (assert) => {
|
|
26
|
+
assertType(assert, "string");
|
|
27
|
+
if (typeof message === "string")
|
|
28
|
+
assert.toStrictlyEqual(message);
|
|
29
|
+
else
|
|
30
|
+
assert.toMatch(message);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var ToBeGreaterThan = class {
|
|
35
|
+
expect(context, negative, value) {
|
|
36
|
+
assertType(context, typeof value);
|
|
37
|
+
if (context.value > value !== negative)
|
|
38
|
+
return;
|
|
39
|
+
throw new ExpectationError(context, negative, `to be greater than ${stringifyValue(value)}`);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var ToBeGreaterThanOrEqual = class {
|
|
43
|
+
expect(context, negative, value) {
|
|
44
|
+
assertType(context, typeof value);
|
|
45
|
+
if (context.value >= value !== negative)
|
|
46
|
+
return;
|
|
47
|
+
throw new ExpectationError(context, negative, `to be greater than or equal to ${stringifyValue(value)}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var ToBeInstanceOf = class {
|
|
51
|
+
expect(context, negative, value) {
|
|
52
|
+
const match = context.value instanceof value;
|
|
53
|
+
if (match !== negative)
|
|
54
|
+
return;
|
|
55
|
+
throw new ExpectationError(context, negative, `to be an instance of ${stringifyConstructor(value)}`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var ToBeLessThan = class {
|
|
59
|
+
expect(context, negative, value) {
|
|
60
|
+
assertType(context, typeof value);
|
|
61
|
+
if (context.value < value !== negative)
|
|
62
|
+
return;
|
|
63
|
+
throw new ExpectationError(context, negative, `to be less than ${stringifyValue(value)}`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var ToBeLessThanOrEqual = class {
|
|
67
|
+
expect(context, negative, value) {
|
|
68
|
+
assertType(context, typeof value);
|
|
69
|
+
if (context.value <= value !== negative)
|
|
70
|
+
return;
|
|
71
|
+
throw new ExpectationError(context, negative, `to be less than or equal to ${stringifyValue(value)}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var ToBeWithinRange = class {
|
|
75
|
+
expect(context, negative, ...[min, max]) {
|
|
76
|
+
if (max < min) {
|
|
77
|
+
const num = max;
|
|
78
|
+
max = min;
|
|
79
|
+
min = num;
|
|
80
|
+
}
|
|
81
|
+
assertType(context, typeof min);
|
|
82
|
+
if ((context.value >= min && context.value <= max) !== negative)
|
|
83
|
+
return;
|
|
84
|
+
throw new ExpectationError(context, negative, `to be within ${stringifyValue(min)}...${stringifyValue(max)}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var ToEqual = class {
|
|
88
|
+
expect(context, negative, expected) {
|
|
89
|
+
const result = diff(context.value, expected);
|
|
90
|
+
if (result.diff === negative)
|
|
91
|
+
return;
|
|
92
|
+
throw new ExpectationError(context, negative, `to equal ${stringifyValue(expected)}`, result);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var ToHaveLength = class {
|
|
96
|
+
expect(context, negative, length) {
|
|
97
|
+
context.toBeDefined();
|
|
98
|
+
const actualLength = context.value.length;
|
|
99
|
+
if (typeof actualLength !== "number") {
|
|
100
|
+
throw new ExpectationError(context, false, 'to have a numeric "length" property');
|
|
101
|
+
}
|
|
102
|
+
if (actualLength === length === negative) {
|
|
103
|
+
throw new ExpectationError(context, negative, `to have length ${stringifyValue(length)}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var ToHaveProperty = class {
|
|
108
|
+
expect(context, negative, prop, assert) {
|
|
109
|
+
context.toBeDefined();
|
|
110
|
+
const match = context.value[prop] !== void 0;
|
|
111
|
+
if (match === negative) {
|
|
112
|
+
throw new ExpectationError(context, negative, `to have property "${String(prop)}"`);
|
|
113
|
+
} else if (match && assert) {
|
|
114
|
+
try {
|
|
115
|
+
assert(context.forProperty(prop));
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (error instanceof ExpectationError && error.diff) {
|
|
118
|
+
error.diff = {
|
|
119
|
+
diff: true,
|
|
120
|
+
value: context.value,
|
|
121
|
+
props: { [prop]: error.diff }
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var ToHaveSize = class {
|
|
130
|
+
expect(context, negative, size) {
|
|
131
|
+
context.toBeDefined();
|
|
132
|
+
const actualSize = context.value.size;
|
|
133
|
+
if (typeof actualSize !== "number") {
|
|
134
|
+
throw new ExpectationError(context, false, 'to have a numeric "size" property');
|
|
135
|
+
}
|
|
136
|
+
if (actualSize === size === negative) {
|
|
137
|
+
throw new ExpectationError(context, negative, `to have size ${stringifyValue(size)}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var ToMatch = class {
|
|
142
|
+
expect(context, negative, expr) {
|
|
143
|
+
assertType(context, "string");
|
|
144
|
+
const match = !!context.value.match(expr);
|
|
145
|
+
if (match !== negative)
|
|
146
|
+
return;
|
|
147
|
+
throw new ExpectationError(context, negative, `to match ${stringifyValue(expr)}`);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var ToStrictlyEqual = class {
|
|
151
|
+
expect(context, negative, expected) {
|
|
152
|
+
const value = context.value;
|
|
153
|
+
const match = value === expected;
|
|
154
|
+
if (match !== negative)
|
|
155
|
+
return;
|
|
156
|
+
const diff2 = negative ? void 0 : { diff: true, value, expected };
|
|
157
|
+
throw new ExpectationError(context, negative, `to strictly equal ${stringifyValue(expected)}`, diff2);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
export {
|
|
161
|
+
ToBeA,
|
|
162
|
+
ToBeCloseTo,
|
|
163
|
+
ToBeError,
|
|
164
|
+
ToBeGreaterThan,
|
|
165
|
+
ToBeGreaterThanOrEqual,
|
|
166
|
+
ToBeInstanceOf,
|
|
167
|
+
ToBeLessThan,
|
|
168
|
+
ToBeLessThanOrEqual,
|
|
169
|
+
ToBeWithinRange,
|
|
170
|
+
ToEqual,
|
|
171
|
+
ToHaveLength,
|
|
172
|
+
ToHaveProperty,
|
|
173
|
+
ToHaveSize,
|
|
174
|
+
ToMatch,
|
|
175
|
+
ToStrictlyEqual
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=basic.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/expectation/basic.ts"],
|
|
4
|
+
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,YAAY,kBAAkB,QAAQ,YAAY,sBAAsB,sBAAsB;AAKhG,IAAM,QAAN,MAAmC;AAAA,EACxC,OAAO,SAAuB,UAAmB,MAAsB;AACrE,UAAM,QAAQ,OAAO,SAAS,IAAI;AAClC,QAAI,UAAU;AAAU;AACxB,UAAM,IAAI,iBAAiB,SAAS,UAAU,SAAS,WAAW,IAAI,GAAG;AAAA,EAC3E;AACF;AAEO,IAAM,cAAN,MAAyC;AAAA,EAC9C,OACI,SACA,aACG,CAAE,OAAO,KAAM,GAGd;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