@plugjs/expect5 0.4.4 → 0.4.6
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/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/execution/executor.cjs.map +1 -1
- package/dist/execution/executor.d.ts +1 -1
- package/dist/execution/executor.mjs +1 -1
- package/dist/execution/executor.mjs.map +1 -1
- package/dist/execution/setup.cjs.map +1 -1
- package/dist/execution/setup.d.ts +1 -1
- package/dist/execution/setup.mjs +1 -1
- package/dist/execution/setup.mjs.map +1 -1
- package/dist/expectation/async.cjs +78 -45
- package/dist/expectation/async.cjs.map +1 -1
- package/dist/expectation/async.d.ts +66 -51
- package/dist/expectation/async.mjs +79 -42
- package/dist/expectation/async.mjs.map +1 -1
- package/dist/expectation/diff.cjs.map +1 -1
- package/dist/expectation/diff.mjs +6 -1
- package/dist/expectation/diff.mjs.map +1 -1
- package/dist/expectation/expect.cjs +11 -165
- package/dist/expectation/expect.cjs.map +2 -2
- package/dist/expectation/expect.d.ts +10 -112
- package/dist/expectation/expect.mjs +12 -207
- package/dist/expectation/expect.mjs.map +2 -2
- package/dist/expectation/expectations.cjs +549 -0
- package/dist/expectation/expectations.cjs.map +6 -0
- package/dist/expectation/expectations.d.ts +454 -0
- package/dist/expectation/expectations.mjs +530 -0
- package/dist/expectation/expectations.mjs.map +6 -0
- package/dist/expectation/include.cjs +43 -41
- package/dist/expectation/include.cjs.map +1 -1
- package/dist/expectation/include.d.ts +3 -19
- package/dist/expectation/include.mjs +43 -41
- package/dist/expectation/include.mjs.map +1 -1
- package/dist/expectation/matchers.cjs +350 -0
- package/dist/expectation/matchers.cjs.map +6 -0
- package/dist/expectation/matchers.d.ts +375 -0
- package/dist/expectation/matchers.mjs +328 -0
- package/dist/expectation/matchers.mjs.map +6 -0
- package/dist/expectation/print.cjs.map +1 -1
- package/dist/expectation/print.d.ts +2 -2
- package/dist/expectation/print.mjs.map +1 -1
- package/dist/expectation/types.cjs +17 -23
- package/dist/expectation/types.cjs.map +1 -1
- package/dist/expectation/types.d.ts +7 -51
- package/dist/expectation/types.mjs +17 -22
- package/dist/expectation/types.mjs.map +1 -1
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +11 -12
- package/dist/index.mjs.map +1 -1
- package/dist/test.cjs +33 -5
- package/dist/test.cjs.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/test.mjs +34 -6
- package/dist/test.mjs.map +1 -1
- package/package.json +2 -2
- package/src/cli.mts +1 -1
- package/src/execution/executor.ts +1 -3
- package/src/execution/setup.ts +1 -3
- package/src/expectation/async.ts +145 -145
- package/src/expectation/diff.ts +7 -3
- package/src/expectation/expect.ts +22 -362
- package/src/expectation/expectations.ts +971 -0
- package/src/expectation/include.ts +59 -75
- package/src/expectation/matchers.ts +698 -0
- package/src/expectation/print.ts +8 -4
- package/src/expectation/types.ts +22 -94
- package/src/globals.ts +2 -2
- package/src/index.ts +17 -10
- package/src/test.ts +33 -10
- package/dist/expectation/basic.cjs +0 -188
- package/dist/expectation/basic.cjs.map +0 -6
- package/dist/expectation/basic.d.ts +0 -90
- package/dist/expectation/basic.mjs +0 -156
- package/dist/expectation/basic.mjs.map +0 -6
- package/dist/expectation/throwing.cjs +0 -58
- package/dist/expectation/throwing.cjs.map +0 -6
- package/dist/expectation/throwing.d.ts +0 -36
- package/dist/expectation/throwing.mjs +0 -32
- package/dist/expectation/throwing.mjs.map +0 -6
- package/dist/expectation/trivial.cjs +0 -96
- package/dist/expectation/trivial.cjs.map +0 -6
- package/dist/expectation/trivial.d.ts +0 -13
- package/dist/expectation/trivial.mjs +0 -61
- package/dist/expectation/trivial.mjs.map +0 -6
- package/src/expectation/basic.ts +0 -413
- package/src/expectation/throwing.ts +0 -106
- package/src/expectation/trivial.ts +0 -107
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// expectation/basic.ts
|
|
2
|
-
import { diff } from "./diff.mjs";
|
|
3
|
-
import {
|
|
4
|
-
assertContextType,
|
|
5
|
-
ExpectationError,
|
|
6
|
-
prefixType,
|
|
7
|
-
stringifyConstructor,
|
|
8
|
-
stringifyValue,
|
|
9
|
-
typeOf
|
|
10
|
-
} from "./types.mjs";
|
|
11
|
-
function toBeA(type, assert) {
|
|
12
|
-
const match = typeOf(this.value) === type;
|
|
13
|
-
if (match === this.negative) {
|
|
14
|
-
throw new ExpectationError(this, `to be ${prefixType(type)}`);
|
|
15
|
-
} else if (assert) {
|
|
16
|
-
assert(this.expects);
|
|
17
|
-
}
|
|
18
|
-
return this.expects;
|
|
19
|
-
}
|
|
20
|
-
function toBeCloseTo(value, delta) {
|
|
21
|
-
const min = value - delta;
|
|
22
|
-
const max = value + delta;
|
|
23
|
-
return this.negated.toBeWithinRange(min, max);
|
|
24
|
-
}
|
|
25
|
-
function toBeError(...args) {
|
|
26
|
-
const [constructor, message] = typeof args[0] === "function" ? [args[0], args[1]] : [Error, args[0]];
|
|
27
|
-
this.negated.toBeInstanceOf(constructor);
|
|
28
|
-
if (this.negative || message === void 0)
|
|
29
|
-
return this.expects;
|
|
30
|
-
return this.expects.toHaveProperty("message", (assert) => {
|
|
31
|
-
assert.toBeA("string");
|
|
32
|
-
return typeof message === "string" ? assert.toStrictlyEqual(message) : assert.toMatch(message);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function toBeGreaterThan(value) {
|
|
36
|
-
assertContextType(this, typeof value);
|
|
37
|
-
if (this.value > value !== this.negative)
|
|
38
|
-
return this.expects;
|
|
39
|
-
throw new ExpectationError(this, `to be greater than ${stringifyValue(value)}`);
|
|
40
|
-
}
|
|
41
|
-
function toBeGreaterThanOrEqual(value) {
|
|
42
|
-
assertContextType(this, typeof value);
|
|
43
|
-
if (this.value >= value !== this.negative)
|
|
44
|
-
return this.expects;
|
|
45
|
-
throw new ExpectationError(this, `to be greater than or equal to ${stringifyValue(value)}`);
|
|
46
|
-
}
|
|
47
|
-
function toBeInstanceOf(value) {
|
|
48
|
-
const match = this.value instanceof value;
|
|
49
|
-
if (match !== this.negative)
|
|
50
|
-
return this.expects;
|
|
51
|
-
throw new ExpectationError(this, `to be an instance of ${stringifyConstructor(value)}`);
|
|
52
|
-
}
|
|
53
|
-
function toBeLessThan(value) {
|
|
54
|
-
assertContextType(this, typeof value);
|
|
55
|
-
if (this.value < value !== this.negative)
|
|
56
|
-
return this.expects;
|
|
57
|
-
throw new ExpectationError(this, `to be less than ${stringifyValue(value)}`);
|
|
58
|
-
}
|
|
59
|
-
function toBeLessThanOrEqual(value) {
|
|
60
|
-
assertContextType(this, typeof value);
|
|
61
|
-
if (this.value <= value !== this.negative)
|
|
62
|
-
return this.expects;
|
|
63
|
-
throw new ExpectationError(this, `to be less than or equal to ${stringifyValue(value)}`);
|
|
64
|
-
}
|
|
65
|
-
function toBeWithinRange(min, max) {
|
|
66
|
-
if (max < min) {
|
|
67
|
-
const num = max;
|
|
68
|
-
max = min;
|
|
69
|
-
min = num;
|
|
70
|
-
}
|
|
71
|
-
assertContextType(this, typeof min);
|
|
72
|
-
if ((this.value >= min && this.value <= max) !== this.negative)
|
|
73
|
-
return this.expects;
|
|
74
|
-
throw new ExpectationError(this, `to be within ${stringifyValue(min)}...${stringifyValue(max)}`);
|
|
75
|
-
}
|
|
76
|
-
function toEqual(expected) {
|
|
77
|
-
const result = diff(this.value, expected);
|
|
78
|
-
if (result.diff === this.negative)
|
|
79
|
-
return this.expects;
|
|
80
|
-
throw new ExpectationError(this, `to equal ${stringifyValue(expected)}`, result);
|
|
81
|
-
}
|
|
82
|
-
function toHaveLength(length) {
|
|
83
|
-
this.expects.toBeDefined();
|
|
84
|
-
const actualLength = this.value.length;
|
|
85
|
-
if (typeof actualLength !== "number") {
|
|
86
|
-
throw new ExpectationError(this, 'to have a numeric "length" property', false);
|
|
87
|
-
}
|
|
88
|
-
if (actualLength === length === this.negative) {
|
|
89
|
-
throw new ExpectationError(this, `to have length ${stringifyValue(length)}`);
|
|
90
|
-
}
|
|
91
|
-
return this.expects;
|
|
92
|
-
}
|
|
93
|
-
function toHaveProperty(prop, assert) {
|
|
94
|
-
this.expects.toBeDefined();
|
|
95
|
-
const match = this.value[prop] !== void 0;
|
|
96
|
-
if (match === this.negative) {
|
|
97
|
-
throw new ExpectationError(this, `to have property "${String(prop)}"`);
|
|
98
|
-
} else if (match && assert) {
|
|
99
|
-
try {
|
|
100
|
-
assert(this.forProperty(prop));
|
|
101
|
-
} catch (error) {
|
|
102
|
-
if (error instanceof ExpectationError && error.diff) {
|
|
103
|
-
error.diff = {
|
|
104
|
-
diff: true,
|
|
105
|
-
value: this.value,
|
|
106
|
-
props: { [prop]: error.diff }
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return this.expects;
|
|
113
|
-
}
|
|
114
|
-
function toHaveSize(size) {
|
|
115
|
-
this.expects.toBeDefined();
|
|
116
|
-
const actualSize = this.value.size;
|
|
117
|
-
if (typeof actualSize !== "number") {
|
|
118
|
-
throw new ExpectationError(this, 'to have a numeric "size" property', false);
|
|
119
|
-
}
|
|
120
|
-
if (actualSize === size === this.negative) {
|
|
121
|
-
throw new ExpectationError(this, `to have size ${stringifyValue(size)}`);
|
|
122
|
-
}
|
|
123
|
-
return this.expects;
|
|
124
|
-
}
|
|
125
|
-
function toMatch(expr) {
|
|
126
|
-
assertContextType(this, "string");
|
|
127
|
-
const match = !!this.value.match(expr);
|
|
128
|
-
if (match !== this.negative)
|
|
129
|
-
return this.expects;
|
|
130
|
-
throw new ExpectationError(this, `to match ${stringifyValue(expr)}`);
|
|
131
|
-
}
|
|
132
|
-
function toStrictlyEqual(expected) {
|
|
133
|
-
const match = this.value === expected;
|
|
134
|
-
if (match !== this.negative)
|
|
135
|
-
return this.expects;
|
|
136
|
-
const diff2 = this.negative ? void 0 : { diff: true, value: this.value, expected };
|
|
137
|
-
throw new ExpectationError(this, `to strictly equal ${stringifyValue(expected)}`, diff2);
|
|
138
|
-
}
|
|
139
|
-
export {
|
|
140
|
-
toBeA,
|
|
141
|
-
toBeCloseTo,
|
|
142
|
-
toBeError,
|
|
143
|
-
toBeGreaterThan,
|
|
144
|
-
toBeGreaterThanOrEqual,
|
|
145
|
-
toBeInstanceOf,
|
|
146
|
-
toBeLessThan,
|
|
147
|
-
toBeLessThanOrEqual,
|
|
148
|
-
toBeWithinRange,
|
|
149
|
-
toEqual,
|
|
150
|
-
toHaveLength,
|
|
151
|
-
toHaveProperty,
|
|
152
|
-
toHaveSize,
|
|
153
|
-
toMatch,
|
|
154
|
-
toStrictlyEqual
|
|
155
|
-
};
|
|
156
|
-
//# sourceMappingURL=basic.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/expectation/basic.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6BP,SAAS,MAEL,MACA,QACY;AACd,QAAM,QAAQ,OAAO,KAAK,KAAK,MAAM;AACrC,MAAI,UAAU,KAAK,UAAU;AAC3B,UAAM,IAAI,iBAAiB,MAAM,SAAS,WAAW,IAAI,GAAG;AAAA,EAC9D,WAAW,QAAQ;AACjB,WAAO,KAAK,OAAO;AAAA,EACrB;AACA,SAAO,KAAK;AACd;AAiBA,SAAS,YAEL,OACA,OACY;AACd,QAAM,MAAO,QAAoB;AACjC,QAAM,MAAO,QAAoB;AACjC,SAAO,KAAK,QAAQ,gBAAgB,KAAK,GAAG;AAC9C;AAgCA,SAAS,aAEF,MAKS;AACd,QAAM,CAAE,aAAa,OAAQ,IAC3B,OAAO,KAAK,CAAC,MAAM,aACjB,CAAE,KAAK,CAAC,GAAG,KAAK,CAAC,CAAE,IACnB,CAAE,OAAO,KAA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S,WAEL,MACY;AACd,OAAK,QAAQ,YAAY;AAEzB,QAAM,aAAc,KAAK,MAAc;AACvC,MAAI,OAAO,eAAe,UAAU;AAClC,UAAM,IAAI,iBAAiB,MAAM,qCAAqC,KAAK;AAAA,EAC7E;AAEA,MAAK,eAAe,SAAU,KAAK,UAAU;AAC3C,UAAM,IAAI,iBAAiB,MAAM,gBAAgB,eAAe,IAAI,GAAG;AAAA,EACzE;AAEA,SAAO,KAAK;AACd;AAUA,SAAS,QAEL,MACY;AACd,oBAAkB,MAAM,QAAQ;AAEhC,QAAM,QAAQ,CAAC,CAAE,KAAK,MAAM,MAAM,IAAI;AACtC,MAAI,UAAU,KAAK;AAAU,WAAO,KAAK;AAEzC,QAAM,IAAI,iBAAiB,MAAM,YAAY,eAAe,IAAI,GAAG;AACrE;AASA,SAAS,gBAEL,UACY;AAEd,QAAM,QAAQ,KAAK,UAAU;AAC7B,MAAI,UAAU,KAAK;AAAU,WAAO,KAAK;AAEzC,QAAMA,QAAO,KAAK,WAAW,SAAY,EAAE,MAAM,MAAM,OAAO,KAAK,OAAO,SAAS;AACnF,QAAM,IAAI,iBAAiB,MAAM,qBAAqB,eAAe,QAAQ,KAAKA,KAAI;AACxF;",
|
|
5
|
-
"names": ["diff"]
|
|
6
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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/throwing.ts
|
|
21
|
-
var throwing_exports = {};
|
|
22
|
-
__export(throwing_exports, {
|
|
23
|
-
toThrow: () => toThrow,
|
|
24
|
-
toThrowError: () => toThrowError
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(throwing_exports);
|
|
27
|
-
var import_types = require("./types.cjs");
|
|
28
|
-
function toThrow(assert) {
|
|
29
|
-
(0, import_types.assertContextType)(this, "function");
|
|
30
|
-
let thrown;
|
|
31
|
-
let error;
|
|
32
|
-
try {
|
|
33
|
-
this.value();
|
|
34
|
-
thrown = false;
|
|
35
|
-
error = void 0;
|
|
36
|
-
} catch (caught) {
|
|
37
|
-
thrown = true;
|
|
38
|
-
error = caught;
|
|
39
|
-
}
|
|
40
|
-
if (thrown === this.negative) {
|
|
41
|
-
throw new import_types.ExpectationError(this, "to throw");
|
|
42
|
-
} else if (thrown && assert) {
|
|
43
|
-
assert(this.forValue(error));
|
|
44
|
-
}
|
|
45
|
-
return this.expects;
|
|
46
|
-
}
|
|
47
|
-
function toThrowError(...args) {
|
|
48
|
-
return this.negated.toThrow((assert) => (
|
|
49
|
-
// @ts-ignore // can't reconcile the types with overloads...
|
|
50
|
-
assert.toBeError(...args)
|
|
51
|
-
));
|
|
52
|
-
}
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
toThrow,
|
|
56
|
-
toThrowError
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=throwing.cjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/expectation/throwing.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoD;AAsBpD,SAAS,QAEL,QACY;AACd,sCAAkB,MAAM,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,SAAK,MAAM;AACX,aAAS;AACT,YAAQ;AAAA,EACV,SAAS,QAAP;AACA,aAAS;AACT,YAAQ;AAAA,EACV;AAEA,MAAI,WAAW,KAAK,UAAU;AAC5B,UAAM,IAAI,8BAAiB,MAAM,UAAU;AAAA,EAC7C,WAAW,UAAU,QAAQ;AAC3B,WAAO,KAAK,SAAS,KAAK,CAAC;AAAA,EAC7B;AAEA,SAAO,KAAK;AACd;AAsCA,SAAS,gBAEF,MAOS;AACd,SAAO,KAAK,QAAQ,QAAQ,CAAC;AAAA;AAAA,IAE3B,OAAO,UAAU,GAAG,IAAI;AAAA,GAAC;AAC7B;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { AssertionFunction, Constructor, JoinExpectations } from './types';
|
|
2
|
-
/** Expects the value to be a `function` throwing _anything_. */
|
|
3
|
-
declare function toThrow<T>(this: T): JoinExpectations<T, Function>;
|
|
4
|
-
/**
|
|
5
|
-
* Expects the value to be a `function` throwing, and asserts the
|
|
6
|
-
* thrown value with the specified callback.
|
|
7
|
-
*/
|
|
8
|
-
declare function toThrow<T>(this: T, assert: AssertionFunction): JoinExpectations<T, Function>;
|
|
9
|
-
/** Expects the value to be a `function` throwing an {@link Error}. */
|
|
10
|
-
declare function toThrowError<T>(this: T): JoinExpectations<T, Function>;
|
|
11
|
-
/**
|
|
12
|
-
* Expects the value to be a `function` throwing an {@link Error} with the
|
|
13
|
-
* specified _message_.
|
|
14
|
-
*/
|
|
15
|
-
declare function toThrowError<T>(this: T, message: string): JoinExpectations<T, Function>;
|
|
16
|
-
/**
|
|
17
|
-
* Expects the value to be a `function` throwing an {@link Error} with its
|
|
18
|
-
* _message_ matching the specified {@link RegExp}.
|
|
19
|
-
*/
|
|
20
|
-
declare function toThrowError<T>(this: T, expession: RegExp): JoinExpectations<T, Function>;
|
|
21
|
-
/**
|
|
22
|
-
* Expects the value to be a `function` throwing an {@link Error} of the
|
|
23
|
-
* specified _type_.
|
|
24
|
-
*/
|
|
25
|
-
declare function toThrowError<T>(this: T, constructor: Constructor<Error>): JoinExpectations<T, Function>;
|
|
26
|
-
/**
|
|
27
|
-
* Expects the value to be a `function` throwing an {@link Error} of the
|
|
28
|
-
* specified _type_ with the specified _message_.
|
|
29
|
-
*/
|
|
30
|
-
declare function toThrowError<T>(this: T, constructor: Constructor<Error>, message: string): JoinExpectations<T, Function>;
|
|
31
|
-
/**
|
|
32
|
-
* Expects the value to be a `function` throwing an {@link Error} of the
|
|
33
|
-
* specified _type_ with its _message_ matching the specified {@link RegExp}.
|
|
34
|
-
*/
|
|
35
|
-
declare function toThrowError<T>(this: T, constructor: Constructor<Error>, expression: RegExp): JoinExpectations<T, Function>;
|
|
36
|
-
export { toThrow, toThrowError, };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// expectation/throwing.ts
|
|
2
|
-
import { ExpectationError, assertContextType } from "./types.mjs";
|
|
3
|
-
function toThrow(assert) {
|
|
4
|
-
assertContextType(this, "function");
|
|
5
|
-
let thrown;
|
|
6
|
-
let error;
|
|
7
|
-
try {
|
|
8
|
-
this.value();
|
|
9
|
-
thrown = false;
|
|
10
|
-
error = void 0;
|
|
11
|
-
} catch (caught) {
|
|
12
|
-
thrown = true;
|
|
13
|
-
error = caught;
|
|
14
|
-
}
|
|
15
|
-
if (thrown === this.negative) {
|
|
16
|
-
throw new ExpectationError(this, "to throw");
|
|
17
|
-
} else if (thrown && assert) {
|
|
18
|
-
assert(this.forValue(error));
|
|
19
|
-
}
|
|
20
|
-
return this.expects;
|
|
21
|
-
}
|
|
22
|
-
function toThrowError(...args) {
|
|
23
|
-
return this.negated.toThrow((assert) => (
|
|
24
|
-
// @ts-ignore // can't reconcile the types with overloads...
|
|
25
|
-
assert.toBeError(...args)
|
|
26
|
-
));
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
toThrow,
|
|
30
|
-
toThrowError
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=throwing.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/expectation/throwing.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,kBAAkB,yBAAyB;AAsBpD,SAAS,QAEL,QACY;AACd,oBAAkB,MAAM,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,SAAK,MAAM;AACX,aAAS;AACT,YAAQ;AAAA,EACV,SAAS,QAAP;AACA,aAAS;AACT,YAAQ;AAAA,EACV;AAEA,MAAI,WAAW,KAAK,UAAU;AAC5B,UAAM,IAAI,iBAAiB,MAAM,UAAU;AAAA,EAC7C,WAAW,UAAU,QAAQ;AAC3B,WAAO,KAAK,SAAS,KAAK,CAAC;AAAA,EAC7B;AAEA,SAAO,KAAK;AACd;AAsCA,SAAS,gBAEF,MAOS;AACd,SAAO,KAAK,QAAQ,QAAQ,CAAC;AAAA;AAAA,IAE3B,OAAO,UAAU,GAAG,IAAI;AAAA,GAAC;AAC7B;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
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/trivial.ts
|
|
21
|
-
var trivial_exports = {};
|
|
22
|
-
__export(trivial_exports, {
|
|
23
|
-
toBeDefined: () => toBeDefined,
|
|
24
|
-
toBeFalse: () => toBeFalse,
|
|
25
|
-
toBeFalsy: () => toBeFalsy,
|
|
26
|
-
toBeNaN: () => toBeNaN,
|
|
27
|
-
toBeNegativeInfinity: () => toBeNegativeInfinity,
|
|
28
|
-
toBeNull: () => toBeNull,
|
|
29
|
-
toBeNullable: () => toBeNullable,
|
|
30
|
-
toBePositiveInfinity: () => toBePositiveInfinity,
|
|
31
|
-
toBeTrue: () => toBeTrue,
|
|
32
|
-
toBeTruthy: () => toBeTruthy,
|
|
33
|
-
toBeUndefined: () => toBeUndefined
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(trivial_exports);
|
|
36
|
-
var import_types = require("./types.cjs");
|
|
37
|
-
function toBeDefined() {
|
|
38
|
-
return check(this, "to be defined", (value) => value !== null && value !== void 0);
|
|
39
|
-
}
|
|
40
|
-
function toBeFalse() {
|
|
41
|
-
return check(this, `to be ${(0, import_types.stringifyValue)(false)}`, (value) => value === false);
|
|
42
|
-
}
|
|
43
|
-
function toBeFalsy() {
|
|
44
|
-
return check(this, "to be falsy", (value) => !value);
|
|
45
|
-
}
|
|
46
|
-
function toBeNaN() {
|
|
47
|
-
return check(this, `to be ${(0, import_types.stringifyValue)(NaN)}`, (value) => typeof value === "number" && isNaN(value));
|
|
48
|
-
}
|
|
49
|
-
function toBeNegativeInfinity() {
|
|
50
|
-
return check(this, `to equal ${(0, import_types.stringifyValue)(Number.NEGATIVE_INFINITY)}`, (value) => value === Number.NEGATIVE_INFINITY);
|
|
51
|
-
}
|
|
52
|
-
function toBeNull() {
|
|
53
|
-
return check(this, `to be ${(0, import_types.stringifyValue)(null)}`, (value) => value === null);
|
|
54
|
-
}
|
|
55
|
-
function toBeNullable() {
|
|
56
|
-
return check(
|
|
57
|
-
this,
|
|
58
|
-
`to be ${(0, import_types.stringifyValue)(null)} or ${(0, import_types.stringifyValue)(void 0)}`,
|
|
59
|
-
(value) => value === null || value === void 0
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
function toBePositiveInfinity() {
|
|
63
|
-
return check(this, `to equal ${(0, import_types.stringifyValue)(Number.POSITIVE_INFINITY)}`, (value) => value === Number.POSITIVE_INFINITY);
|
|
64
|
-
}
|
|
65
|
-
function toBeTrue() {
|
|
66
|
-
return check(this, `to be ${(0, import_types.stringifyValue)(true)}`, (value) => value === true);
|
|
67
|
-
}
|
|
68
|
-
function toBeTruthy() {
|
|
69
|
-
return check(this, "to be truthy", (value) => !!value);
|
|
70
|
-
}
|
|
71
|
-
function toBeUndefined() {
|
|
72
|
-
return check(this, `to be ${(0, import_types.stringifyValue)(void 0)}`, (value) => value === void 0);
|
|
73
|
-
}
|
|
74
|
-
function check(context, details, cb) {
|
|
75
|
-
const match = cb(context.value);
|
|
76
|
-
if (match === context.negative) {
|
|
77
|
-
throw new import_types.ExpectationError(context, details);
|
|
78
|
-
} else {
|
|
79
|
-
return context.expects;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
toBeDefined,
|
|
85
|
-
toBeFalse,
|
|
86
|
-
toBeFalsy,
|
|
87
|
-
toBeNaN,
|
|
88
|
-
toBeNegativeInfinity,
|
|
89
|
-
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,MAAM,MAAM,gBAAY,6BAAe,OAAO,iBAAiB,KAAK,CAAC,UAAU,UAAU,OAAO,iBAAiB;AAC1H;AAIA,SAAS,WAAkD;AACzD,SAAO,MAAM,MAAM,aAAS,6BAAe,IAAI,KAAK,CAAC,UAAU,UAAU,IAAI;AAC/E;AAIA,SAAS,aAAmD;AAC1D,SAAO,MAAM,MAAM,gBAAgB,CAAC,UAAU,CAAC,CAAE,KAAK;AACxD;AAIA,SAAS,gBAAuD;AAC9D,SAAO,MAAM,MAAM,aAAS,6BAAe,MAAS,KAAK,CAAC,UAAU,UAAU,MAAS;AACzF;AAuBA,SAAS,MACL,SACA,SACA,IACY;AACd,QAAM,QAAQ,GAAG,QAAQ,KAAK;AAC9B,MAAI,UAAU,QAAQ,UAAU;AAC9B,UAAM,IAAI,8BAAiB,SAAS,OAAO;AAAA,EAC7C,OAAO;AACL,WAAO,QAAQ;AAAA,EACjB;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Expectations } from './expect';
|
|
2
|
-
declare function toBeDefined<T>(this: T): T;
|
|
3
|
-
declare function toBeFalse(): Expectations<false>;
|
|
4
|
-
declare function toBeFalsy<T>(this: T): T;
|
|
5
|
-
declare function toBeNaN(): Expectations<number>;
|
|
6
|
-
declare function toBeNegativeInfinity(): Expectations<number>;
|
|
7
|
-
declare function toBeNull(): Expectations<null>;
|
|
8
|
-
declare function toBeNullable(): Expectations<null | undefined>;
|
|
9
|
-
declare function toBePositiveInfinity(): Expectations<number>;
|
|
10
|
-
declare function toBeTrue(): Expectations<true>;
|
|
11
|
-
declare function toBeTruthy<T>(this: T): T;
|
|
12
|
-
declare function toBeUndefined(): Expectations<undefined>;
|
|
13
|
-
export { toBeDefined, toBeFalse, toBeFalsy, toBeNaN, toBeNegativeInfinity, toBeNull, toBeNullable, toBePositiveInfinity, toBeTrue, toBeTruthy, toBeUndefined, };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// expectation/trivial.ts
|
|
2
|
-
import { ExpectationError, stringifyValue } from "./types.mjs";
|
|
3
|
-
function toBeDefined() {
|
|
4
|
-
return check(this, "to be defined", (value) => value !== null && value !== void 0);
|
|
5
|
-
}
|
|
6
|
-
function toBeFalse() {
|
|
7
|
-
return check(this, `to be ${stringifyValue(false)}`, (value) => value === false);
|
|
8
|
-
}
|
|
9
|
-
function toBeFalsy() {
|
|
10
|
-
return check(this, "to be falsy", (value) => !value);
|
|
11
|
-
}
|
|
12
|
-
function toBeNaN() {
|
|
13
|
-
return check(this, `to be ${stringifyValue(NaN)}`, (value) => typeof value === "number" && isNaN(value));
|
|
14
|
-
}
|
|
15
|
-
function toBeNegativeInfinity() {
|
|
16
|
-
return check(this, `to equal ${stringifyValue(Number.NEGATIVE_INFINITY)}`, (value) => value === Number.NEGATIVE_INFINITY);
|
|
17
|
-
}
|
|
18
|
-
function toBeNull() {
|
|
19
|
-
return check(this, `to be ${stringifyValue(null)}`, (value) => value === null);
|
|
20
|
-
}
|
|
21
|
-
function toBeNullable() {
|
|
22
|
-
return check(
|
|
23
|
-
this,
|
|
24
|
-
`to be ${stringifyValue(null)} or ${stringifyValue(void 0)}`,
|
|
25
|
-
(value) => value === null || value === void 0
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function toBePositiveInfinity() {
|
|
29
|
-
return check(this, `to equal ${stringifyValue(Number.POSITIVE_INFINITY)}`, (value) => value === Number.POSITIVE_INFINITY);
|
|
30
|
-
}
|
|
31
|
-
function toBeTrue() {
|
|
32
|
-
return check(this, `to be ${stringifyValue(true)}`, (value) => value === true);
|
|
33
|
-
}
|
|
34
|
-
function toBeTruthy() {
|
|
35
|
-
return check(this, "to be truthy", (value) => !!value);
|
|
36
|
-
}
|
|
37
|
-
function toBeUndefined() {
|
|
38
|
-
return check(this, `to be ${stringifyValue(void 0)}`, (value) => value === void 0);
|
|
39
|
-
}
|
|
40
|
-
function check(context, details, cb) {
|
|
41
|
-
const match = cb(context.value);
|
|
42
|
-
if (match === context.negative) {
|
|
43
|
-
throw new ExpectationError(context, details);
|
|
44
|
-
} else {
|
|
45
|
-
return context.expects;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
toBeDefined,
|
|
50
|
-
toBeFalse,
|
|
51
|
-
toBeFalsy,
|
|
52
|
-
toBeNaN,
|
|
53
|
-
toBeNegativeInfinity,
|
|
54
|
-
toBeNull,
|
|
55
|
-
toBeNullable,
|
|
56
|
-
toBePositiveInfinity,
|
|
57
|
-
toBeTrue,
|
|
58
|
-
toBeTruthy,
|
|
59
|
-
toBeUndefined
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=trivial.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/expectation/trivial.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,kBAAkB,sBAAsB;AAOjD,SAAS,cAAqD;AAC5D,SAAO,MAAM,MAAM,iBAAiB,CAAC,UAAW,UAAU,QAAU,UAAU,MAAU;AAC1F;AAIA,SAAS,YAAmD;AAC1D,SAAO,MAAM,MAAM,SAAS,eAAe,KAAK,KAAK,CAAC,UAAU,UAAU,KAAK;AACjF;AAIA,SAAS,YAAmD;AAC1D,SAAO,MAAM,MAAM,eAAe,CAAC,UAAU,CAAE,KAAK;AACtD;AAIA,SAAS,UAAiD;AACxD,SAAO,MAAM,MAAM,SAAS,eAAe,GAAG,KAAK,CAAC,UAAW,OAAO,UAAU,YAAa,MAAM,KAAK,CAAC;AAC3G;AAIA,SAAS,uBAA8D;AACrE,SAAO,MAAM,MAAM,YAAY,eAAe,OAAO,iBAAiB,KAAK,CAAC,UAAU,UAAU,OAAO,iBAAiB;AAC1H;AAIA,SAAS,WAAkD;AACzD,SAAO,MAAM,MAAM,SAAS,eAAe,IAAI,KAAK,CAAC,UAAU,UAAU,IAAI;AAC/E;AAIA,SAAS,eAAs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