assertron 7.1.2 → 9.0.1
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/LICENSE +2 -2
- package/README.md +61 -46
- package/package.json +62 -24
- package/src/assert-order/AssertOrder.spec.ts +10 -12
- package/src/assert-order/AssertOrder.ts +8 -8
- package/src/assert-order/InvalidOrder.ts +7 -12
- package/src/assert-order/StateMachine.ts +26 -31
- package/src/assert-order/index.ts +3 -1
- package/src/assert-order/internalInterfaces.ts +3 -3
- package/src/assert-order/types.ts +7 -0
- package/src/assertron/assertron.spec.ts +2 -4
- package/src/assertron/assertron.ts +13 -14
- package/src/assertron/falsy.spec.ts +2 -3
- package/src/assertron/falsy.ts +2 -6
- package/src/assertron/pathEqual.spec.ts +2 -3
- package/src/assertron/pathEqual.ts +4 -7
- package/src/assertron/rejects.spec.ts +7 -8
- package/src/assertron/rejects.ts +3 -11
- package/src/assertron/repeat.spec.ts +8 -10
- package/src/assertron/repeat.ts +4 -9
- package/src/assertron/resolves.spec.ts +3 -4
- package/src/assertron/resolves.ts +3 -13
- package/src/assertron/satisfies.spec.ts +57 -26
- package/src/assertron/satisfies.ts +23 -10
- package/src/assertron/throws.spec.ts +58 -39
- package/src/assertron/throws.ts +30 -54
- package/src/assertron/truthy.spec.ts +2 -3
- package/src/assertron/truthy.ts +2 -3
- package/src/errors.ts +22 -0
- package/src/index.ts +2 -1
- package/src/testUtils.ts +16 -13
- package/src/{errors/interfaces.ts → types.ts} +1 -1
- package/src/utils/index.ts +12 -0
- package/src/utils/isErrorConstructor.ts +5 -0
- package/src/utils/notEqualMessage.ts +4 -0
- package/src/{errors → utils}/notSatisfiedMessage.spec.ts +0 -0
- package/src/{errors/NotSatisfied.ts → utils/notSatisfiedMessage.ts} +1 -1
- package/src/utils/notThrownMessage.ts +5 -0
- package/src/utils/promiseMessages.ts +12 -0
- package/src/{errors → utils}/unexpectedErrorMessage.ts +4 -3
- package/dist-es2015/assert-order/AssertOrder.d.ts +0 -40
- package/dist-es2015/assert-order/AssertOrder.js +0 -132
- package/dist-es2015/assert-order/AssertOrder.js.map +0 -1
- package/dist-es2015/assert-order/InvalidOrder.d.ts +0 -8
- package/dist-es2015/assert-order/InvalidOrder.js +0 -31
- package/dist-es2015/assert-order/InvalidOrder.js.map +0 -1
- package/dist-es2015/assert-order/StateMachine.d.ts +0 -23
- package/dist-es2015/assert-order/StateMachine.js +0 -106
- package/dist-es2015/assert-order/StateMachine.js.map +0 -1
- package/dist-es2015/assert-order/index.d.ts +0 -2
- package/dist-es2015/assert-order/index.js +0 -2
- package/dist-es2015/assert-order/index.js.map +0 -1
- package/dist-es2015/assert-order/interfaces.d.ts +0 -7
- package/dist-es2015/assert-order/interfaces.js +0 -1
- package/dist-es2015/assert-order/interfaces.js.map +0 -1
- package/dist-es2015/assertron/assertron.d.ts +0 -20
- package/dist-es2015/assertron/assertron.js +0 -28
- package/dist-es2015/assertron/assertron.js.map +0 -1
- package/dist-es2015/assertron/falsy.d.ts +0 -1
- package/dist-es2015/assertron/falsy.js +0 -6
- package/dist-es2015/assertron/falsy.js.map +0 -1
- package/dist-es2015/assertron/index.d.ts +0 -1
- package/dist-es2015/assertron/index.js +0 -2
- package/dist-es2015/assertron/index.js.map +0 -1
- package/dist-es2015/assertron/pathEqual.d.ts +0 -1
- package/dist-es2015/assertron/pathEqual.js +0 -8
- package/dist-es2015/assertron/pathEqual.js.map +0 -1
- package/dist-es2015/assertron/rejects.d.ts +0 -1
- package/dist-es2015/assertron/rejects.js +0 -10
- package/dist-es2015/assertron/rejects.js.map +0 -1
- package/dist-es2015/assertron/repeat.d.ts +0 -11
- package/dist-es2015/assertron/repeat.js +0 -35
- package/dist-es2015/assertron/repeat.js.map +0 -1
- package/dist-es2015/assertron/resolves.d.ts +0 -1
- package/dist-es2015/assertron/resolves.js +0 -12
- package/dist-es2015/assertron/resolves.js.map +0 -1
- package/dist-es2015/assertron/satisfies.d.ts +0 -5
- package/dist-es2015/assertron/satisfies.js +0 -14
- package/dist-es2015/assertron/satisfies.js.map +0 -1
- package/dist-es2015/assertron/throws.d.ts +0 -5
- package/dist-es2015/assertron/throws.js +0 -55
- package/dist-es2015/assertron/throws.js.map +0 -1
- package/dist-es2015/assertron/truthy.d.ts +0 -1
- package/dist-es2015/assertron/truthy.js +0 -6
- package/dist-es2015/assertron/truthy.js.map +0 -1
- package/dist-es2015/errors/NotSatisfied.d.ts +0 -2
- package/dist-es2015/errors/NotSatisfied.js +0 -23
- package/dist-es2015/errors/NotSatisfied.js.map +0 -1
- package/dist-es2015/errors/index.d.ts +0 -7
- package/dist-es2015/errors/index.js +0 -7
- package/dist-es2015/errors/index.js.map +0 -1
- package/dist-es2015/errors/interfaces.d.ts +0 -2
- package/dist-es2015/errors/interfaces.js +0 -1
- package/dist-es2015/errors/interfaces.js.map +0 -1
- package/dist-es2015/errors/notEqualMessage.d.ts +0 -1
- package/dist-es2015/errors/notEqualMessage.js +0 -4
- package/dist-es2015/errors/notEqualMessage.js.map +0 -1
- package/dist-es2015/errors/notRejectedMessage.d.ts +0 -1
- package/dist-es2015/errors/notRejectedMessage.js +0 -4
- package/dist-es2015/errors/notRejectedMessage.js.map +0 -1
- package/dist-es2015/errors/notThrownMessage.d.ts +0 -1
- package/dist-es2015/errors/notThrownMessage.js +0 -4
- package/dist-es2015/errors/notThrownMessage.js.map +0 -1
- package/dist-es2015/errors/returnNotRejectedMessage.d.ts +0 -1
- package/dist-es2015/errors/returnNotRejectedMessage.js +0 -4
- package/dist-es2015/errors/returnNotRejectedMessage.js.map +0 -1
- package/dist-es2015/errors/unexpectedErrorMessage.d.ts +0 -2
- package/dist-es2015/errors/unexpectedErrorMessage.js +0 -6
- package/dist-es2015/errors/unexpectedErrorMessage.js.map +0 -1
- package/dist-es2015/errors/util.d.ts +0 -2
- package/dist-es2015/errors/util.js +0 -4
- package/dist-es2015/errors/util.js.map +0 -1
- package/dist-es2015/index.d.ts +0 -4
- package/dist-es2015/index.js +0 -5
- package/dist-es2015/index.js.map +0 -1
- package/dist-es5/assert-order/AssertOrder.d.ts +0 -40
- package/dist-es5/assert-order/AssertOrder.js +0 -147
- package/dist-es5/assert-order/AssertOrder.js.map +0 -1
- package/dist-es5/assert-order/InvalidOrder.d.ts +0 -8
- package/dist-es5/assert-order/InvalidOrder.js +0 -58
- package/dist-es5/assert-order/InvalidOrder.js.map +0 -1
- package/dist-es5/assert-order/StateMachine.d.ts +0 -23
- package/dist-es5/assert-order/StateMachine.js +0 -115
- package/dist-es5/assert-order/StateMachine.js.map +0 -1
- package/dist-es5/assert-order/index.d.ts +0 -2
- package/dist-es5/assert-order/index.js +0 -7
- package/dist-es5/assert-order/index.js.map +0 -1
- package/dist-es5/assert-order/interfaces.d.ts +0 -7
- package/dist-es5/assert-order/interfaces.js +0 -3
- package/dist-es5/assert-order/interfaces.js.map +0 -1
- package/dist-es5/assertron/assertron.d.ts +0 -20
- package/dist-es5/assertron/assertron.js +0 -33
- package/dist-es5/assertron/assertron.js.map +0 -1
- package/dist-es5/assertron/falsy.d.ts +0 -1
- package/dist-es5/assertron/falsy.js +0 -12
- package/dist-es5/assertron/falsy.js.map +0 -1
- package/dist-es5/assertron/index.d.ts +0 -1
- package/dist-es5/assertron/index.js +0 -7
- package/dist-es5/assertron/index.js.map +0 -1
- package/dist-es5/assertron/pathEqual.d.ts +0 -1
- package/dist-es5/assertron/pathEqual.js +0 -14
- package/dist-es5/assertron/pathEqual.js.map +0 -1
- package/dist-es5/assertron/rejects.d.ts +0 -1
- package/dist-es5/assertron/rejects.js +0 -16
- package/dist-es5/assertron/rejects.js.map +0 -1
- package/dist-es5/assertron/repeat.d.ts +0 -11
- package/dist-es5/assertron/repeat.js +0 -58
- package/dist-es5/assertron/repeat.js.map +0 -1
- package/dist-es5/assertron/resolves.d.ts +0 -1
- package/dist-es5/assertron/resolves.js +0 -18
- package/dist-es5/assertron/resolves.js.map +0 -1
- package/dist-es5/assertron/satisfies.d.ts +0 -5
- package/dist-es5/assertron/satisfies.js +0 -20
- package/dist-es5/assertron/satisfies.js.map +0 -1
- package/dist-es5/assertron/throws.d.ts +0 -5
- package/dist-es5/assertron/throws.js +0 -61
- package/dist-es5/assertron/throws.js.map +0 -1
- package/dist-es5/assertron/truthy.d.ts +0 -1
- package/dist-es5/assertron/truthy.js +0 -12
- package/dist-es5/assertron/truthy.js.map +0 -1
- package/dist-es5/errors/NotSatisfied.d.ts +0 -2
- package/dist-es5/errors/NotSatisfied.js +0 -26
- package/dist-es5/errors/NotSatisfied.js.map +0 -1
- package/dist-es5/errors/index.d.ts +0 -7
- package/dist-es5/errors/index.js +0 -12
- package/dist-es5/errors/index.js.map +0 -1
- package/dist-es5/errors/interfaces.d.ts +0 -2
- package/dist-es5/errors/interfaces.js +0 -3
- package/dist-es5/errors/interfaces.js.map +0 -1
- package/dist-es5/errors/notEqualMessage.d.ts +0 -1
- package/dist-es5/errors/notEqualMessage.js +0 -7
- package/dist-es5/errors/notEqualMessage.js.map +0 -1
- package/dist-es5/errors/notRejectedMessage.d.ts +0 -1
- package/dist-es5/errors/notRejectedMessage.js +0 -7
- package/dist-es5/errors/notRejectedMessage.js.map +0 -1
- package/dist-es5/errors/notThrownMessage.d.ts +0 -1
- package/dist-es5/errors/notThrownMessage.js +0 -7
- package/dist-es5/errors/notThrownMessage.js.map +0 -1
- package/dist-es5/errors/returnNotRejectedMessage.d.ts +0 -1
- package/dist-es5/errors/returnNotRejectedMessage.js +0 -7
- package/dist-es5/errors/returnNotRejectedMessage.js.map +0 -1
- package/dist-es5/errors/unexpectedErrorMessage.d.ts +0 -2
- package/dist-es5/errors/unexpectedErrorMessage.js +0 -9
- package/dist-es5/errors/unexpectedErrorMessage.js.map +0 -1
- package/dist-es5/errors/util.d.ts +0 -2
- package/dist-es5/errors/util.js +0 -7
- package/dist-es5/errors/util.js.map +0 -1
- package/dist-es5/index.d.ts +0 -4
- package/dist-es5/index.js +0 -10
- package/dist-es5/index.js.map +0 -1
- package/src/assert-order/interfaces.ts +0 -7
- package/src/errors/index.ts +0 -7
- package/src/errors/notEqualMessage.ts +0 -3
- package/src/errors/notRejectedMessage.ts +0 -3
- package/src/errors/notThrownMessage.ts +0 -3
- package/src/errors/returnNotRejectedMessage.ts +0 -3
- package/src/errors/util.ts +0 -5
package/src/assertron/throws.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import AssertionError from 'assertion-error';
|
|
2
1
|
import isPromise from 'is-promise';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { AssertionError } from '../errors';
|
|
3
|
+
import { ErrorConstructor, ErrorValidator } from '../types';
|
|
4
|
+
import { isErrorConstructor, notRejectedMessage, notThrownMessage, unexpectedErrorMessage } from '../utils';
|
|
5
5
|
|
|
6
6
|
export function throws<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>
|
|
7
7
|
export function throws<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E
|
|
@@ -10,54 +10,38 @@ export function throws<T, R = any>(value: (...args: any[]) => R, validator?: Err
|
|
|
10
10
|
export function throws(value: PromiseLike<any> | (() => any | PromiseLike<any>), validator?: ErrorValidator | ErrorConstructor<any>): any {
|
|
11
11
|
if (typeof value !== 'function' && !isPromise(value)) {
|
|
12
12
|
throw new AssertionError(
|
|
13
|
-
'`assertron.throws()` must be called with a
|
|
14
|
-
|
|
15
|
-
throws
|
|
13
|
+
'`assertron.throws()` must be called with a function or promise.',
|
|
14
|
+
{ ssf: throws }
|
|
16
15
|
)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
if (isPromise(value)) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{ value },
|
|
25
|
-
throws)
|
|
26
|
-
},
|
|
27
|
-
err => {
|
|
28
|
-
validateError(validator, err)
|
|
29
|
-
return err
|
|
18
|
+
if (!isPromise(value)) {
|
|
19
|
+
const { threw, err, result } = tryCatch(value)
|
|
20
|
+
if (threw) {
|
|
21
|
+
if (failValidation(validator, err)) {
|
|
22
|
+
throw new AssertionError(unexpectedErrorMessage(err, validator), { ssf: throws })
|
|
30
23
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (threw) {
|
|
35
|
-
validateError(validator, err)
|
|
36
|
-
return err
|
|
24
|
+
return err
|
|
25
|
+
}
|
|
26
|
+
value = result;
|
|
37
27
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
returnNotRejectedMessage(value),
|
|
43
|
-
{ value },
|
|
44
|
-
throws)
|
|
45
|
-
},
|
|
28
|
+
|
|
29
|
+
if (isPromise(value)) {
|
|
30
|
+
return value.then(
|
|
31
|
+
value => { throw new AssertionError(notRejectedMessage(value), { ssf: throws }) },
|
|
46
32
|
err => {
|
|
47
|
-
|
|
33
|
+
if (failValidation(validator, err)) {
|
|
34
|
+
throw new AssertionError(unexpectedErrorMessage(err, validator), { ssf: throws })
|
|
35
|
+
}
|
|
48
36
|
return err
|
|
49
37
|
}
|
|
50
38
|
)
|
|
51
39
|
}
|
|
52
40
|
|
|
53
|
-
throw new AssertionError(
|
|
54
|
-
notThrownMessage(result),
|
|
55
|
-
{ value: result },
|
|
56
|
-
throws
|
|
57
|
-
)
|
|
41
|
+
throw new AssertionError(notThrownMessage(value), { ssf: throws })
|
|
58
42
|
}
|
|
59
43
|
|
|
60
|
-
function tryCatch(fn) {
|
|
44
|
+
function tryCatch(fn: () => any) {
|
|
61
45
|
let result
|
|
62
46
|
let err
|
|
63
47
|
let threw = false
|
|
@@ -70,22 +54,14 @@ function tryCatch(fn) {
|
|
|
70
54
|
}
|
|
71
55
|
return { threw, err, result }
|
|
72
56
|
}
|
|
57
|
+
function failValidation(validator: ErrorValidator | ErrorConstructor<any> | undefined, error: any): validator is ErrorValidator | ErrorConstructor<any> {
|
|
58
|
+
if (!validator) return false
|
|
73
59
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
unexpectedErrorMessage(error, validator),
|
|
80
|
-
{ actual: error, expected: validator },
|
|
81
|
-
throws
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
else if (!validator(error))
|
|
85
|
-
throw new AssertionError(
|
|
86
|
-
unexpectedErrorMessage(error, validator),
|
|
87
|
-
{ actual: error, expected: validator },
|
|
88
|
-
throws
|
|
89
|
-
)
|
|
60
|
+
if (isErrorConstructor(validator)) {
|
|
61
|
+
return !(error instanceof validator)
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return !validator(error)
|
|
90
65
|
}
|
|
91
66
|
}
|
|
67
|
+
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import AssertionError from '
|
|
2
|
-
import
|
|
3
|
-
import { assertThrows, noStackTraceFor } from '../testUtils';
|
|
1
|
+
import a, { AssertionError } from '..'
|
|
2
|
+
import { assertThrows, noStackTraceFor } from '../testUtils'
|
|
4
3
|
|
|
5
4
|
test('falsy statement throws', () => {
|
|
6
5
|
assertThrows(() => a.truthy(false), AssertionError)
|
package/src/assertron/truthy.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import AssertionError from '
|
|
1
|
+
import { AssertionError } from '../errors';
|
|
2
2
|
|
|
3
3
|
export function truthy(value: any) {
|
|
4
4
|
if (!value) throw new AssertionError(
|
|
5
5
|
`Expected value to be truthy, but received ${value}`,
|
|
6
|
-
{
|
|
7
|
-
truthy
|
|
6
|
+
{ ssf: truthy }
|
|
8
7
|
)
|
|
9
8
|
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IsoError, ModuleError } from 'iso-error'
|
|
2
|
+
import { RequiredPick } from 'type-plus'
|
|
3
|
+
import { failOnOccurrence } from './utils'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A base error for all assertion errors
|
|
7
|
+
*/
|
|
8
|
+
export class AssertionError extends ModuleError {
|
|
9
|
+
constructor(message: string, options: AssertionError.Options) {
|
|
10
|
+
super('assertron', message, options)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export namespace AssertionError {
|
|
15
|
+
export type Options = RequiredPick<IsoError.Options, 'ssf'>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class FailOnOccurrence extends AssertionError {
|
|
19
|
+
constructor(public occurrence: number, public error: any, options: AssertionError.Options) {
|
|
20
|
+
super(failOnOccurrence(occurrence, error), options)
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
CHANGED
package/src/testUtils.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// istanbul ignore file
|
|
2
|
-
import t from 'assert'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { ErrorConstructor } from './errors';
|
|
2
|
+
import t from 'assert'
|
|
3
|
+
import isPromise from 'is-promise'
|
|
4
|
+
import { isError } from 'lodash'
|
|
5
|
+
import { ErrorConstructor } from './types'
|
|
7
6
|
|
|
8
|
-
export
|
|
7
|
+
export type AnyFunction = (...args: any[]) => any
|
|
8
|
+
|
|
9
|
+
export function runAsync(fn: AnyFunction) {
|
|
9
10
|
return new Promise((resolve, reject) => {
|
|
10
11
|
setTimeout(() => {
|
|
11
12
|
try {
|
|
@@ -18,7 +19,7 @@ export function runAsync(fn) {
|
|
|
18
19
|
})
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export function runSequentialAsync(...fns) {
|
|
22
|
+
export function runSequentialAsync(...fns: AnyFunction[]) {
|
|
22
23
|
return new Promise((resolve, reject) => {
|
|
23
24
|
setTimeout(() => {
|
|
24
25
|
try {
|
|
@@ -35,7 +36,7 @@ export function runSequentialAsync(...fns) {
|
|
|
35
36
|
})
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
export function runParallelAsync(...fns) {
|
|
39
|
+
export function runParallelAsync(...fns: AnyFunction[]) {
|
|
39
40
|
return Promise.all(fns.map(fn => runAsync(fn)))
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -48,11 +49,11 @@ export function assertIsError(err: Error) {
|
|
|
48
49
|
t(isError(err))
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
export function assertThrows<E extends Error>(fn, ErrorType?: ErrorConstructor<E>): E {
|
|
52
|
+
export function assertThrows<E extends Error>(fn: AnyFunction, ErrorType?: ErrorConstructor<E>): E {
|
|
52
53
|
try {
|
|
53
54
|
fn()
|
|
54
55
|
}
|
|
55
|
-
catch (e) {
|
|
56
|
+
catch (e: any) {
|
|
56
57
|
if (ErrorType && !(e instanceof ErrorType)) {
|
|
57
58
|
throw new Error(`thrown error ${e} is not of expected type ${ErrorType}`)
|
|
58
59
|
}
|
|
@@ -61,21 +62,23 @@ export function assertThrows<E extends Error>(fn, ErrorType?: ErrorConstructor<E
|
|
|
61
62
|
throw new Error(`${fn} does not throw as expected`)
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
export async function assertAsyncThrows<E extends Error>(fn, ErrorType?: ErrorConstructor<E>): Promise<E> {
|
|
65
|
+
export async function assertAsyncThrows<E extends Error>(fn: AnyFunction, ErrorType?: ErrorConstructor<E>): Promise<E> {
|
|
65
66
|
try {
|
|
66
67
|
await fn()
|
|
67
68
|
}
|
|
68
|
-
catch (e) {
|
|
69
|
+
catch (e: any) {
|
|
70
|
+
// console.log('catch clause', e)
|
|
69
71
|
if (ErrorType && !(e instanceof ErrorType)) {
|
|
70
72
|
throw new Error(`thrown error ${e} is not of expected type ${ErrorType}`)
|
|
71
73
|
}
|
|
74
|
+
// console.log('returning e')
|
|
72
75
|
return e
|
|
73
76
|
}
|
|
74
77
|
throw new Error(`${fn} does not throw as expected`)
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
|
|
78
|
-
export function noStackTraceFor(filename: string, err:
|
|
81
|
+
export function noStackTraceFor(filename: string, err: Error) {
|
|
79
82
|
if (err.stack && RegExp(filename).test(err.stack))
|
|
80
83
|
throw new Error(`contains internal stack: \n${err.stack}`)
|
|
81
84
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { tersify } from 'tersify';
|
|
2
|
+
|
|
3
|
+
export * from './isErrorConstructor';
|
|
4
|
+
export * from './notEqualMessage';
|
|
5
|
+
export * from './notSatisfiedMessage';
|
|
6
|
+
export * from './notThrownMessage';
|
|
7
|
+
export * from './promiseMessages';
|
|
8
|
+
export * from './unexpectedErrorMessage';
|
|
9
|
+
|
|
10
|
+
export function failOnOccurrence(occurrence: number, error: any) {
|
|
11
|
+
return `Failed on ${occurrence} occurrence: ${tersify(error, { maxLength: Infinity })}`
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { tersify } from 'tersify'
|
|
2
|
+
|
|
3
|
+
export function notRejectedMessage(value: any) {
|
|
4
|
+
return `Expected promise to reject, but it resolves with ` + (typeof value === 'string'
|
|
5
|
+
? `'${value}'` : tersify(value, { maxLength: Infinity }))
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function notResolvedMessage(error: any) {
|
|
9
|
+
return `Expected promise to resolve, but it rejects with ` + (typeof error === 'string'
|
|
10
|
+
? `'${error}'` : error instanceof Error ? error : tersify(error, { maxLength: Infinity }))
|
|
11
|
+
}
|
|
12
|
+
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { tersify } from 'tersify';
|
|
2
|
-
import { ErrorConstructor, ErrorValidator } from '
|
|
3
|
-
import { isErrorConstructor } from './
|
|
2
|
+
import { ErrorConstructor, ErrorValidator } from '../types';
|
|
3
|
+
import { isErrorConstructor } from './isErrorConstructor';
|
|
4
4
|
|
|
5
5
|
export function unexpectedErrorMessage(actual: any, expected: ErrorValidator | ErrorConstructor<any>) {
|
|
6
|
-
return `Unexpected error. Expecting '${isErrorConstructor(expected) ?
|
|
6
|
+
return `Unexpected error. Expecting '${isErrorConstructor(expected) ?
|
|
7
|
+
expected.name : tersify(expected)}' but received ${tersify(actual)}`
|
|
7
8
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export declare class AssertOrder {
|
|
2
|
-
/**
|
|
3
|
-
* Gets the current expecting step.
|
|
4
|
-
*/
|
|
5
|
-
readonly currentStep: number;
|
|
6
|
-
private state;
|
|
7
|
-
constructor(plan?: number);
|
|
8
|
-
/**
|
|
9
|
-
* Asserts the current step is `step`.
|
|
10
|
-
* @param step expected step.
|
|
11
|
-
*/
|
|
12
|
-
is(step: number): void;
|
|
13
|
-
/**
|
|
14
|
-
* Asserts the current step is not `step`.
|
|
15
|
-
* @param step not expected step.
|
|
16
|
-
*/
|
|
17
|
-
not(step: number): void;
|
|
18
|
-
/**
|
|
19
|
-
* Reset to specified step.
|
|
20
|
-
*/
|
|
21
|
-
jump(step: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* Move to next step.
|
|
24
|
-
*/
|
|
25
|
-
move(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Asserts the specified step will run once.
|
|
28
|
-
*/
|
|
29
|
-
once(step: number): void;
|
|
30
|
-
on(step: number, assert: (step: number) => void): void;
|
|
31
|
-
atLeastOnce(step: number): number;
|
|
32
|
-
any(steps: number[]): number;
|
|
33
|
-
onAny(steps: number[], ...asserts: Function[]): void;
|
|
34
|
-
end(timeout: number): Promise<number>;
|
|
35
|
-
end(): number;
|
|
36
|
-
exactly(step: number, times: number): number;
|
|
37
|
-
wait(step: number): Promise<void>;
|
|
38
|
-
wait(step: number, callback: () => void): void;
|
|
39
|
-
private assert;
|
|
40
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { InvalidOrder } from './InvalidOrder';
|
|
2
|
-
import { StateMachine } from './StateMachine';
|
|
3
|
-
// order.atLeast(step, count) // expected to be executed at least `count` times
|
|
4
|
-
// order.atMost(step, count) // exected to be executed at most `count` times
|
|
5
|
-
export class AssertOrder {
|
|
6
|
-
/**
|
|
7
|
-
* Gets the current expecting step.
|
|
8
|
-
*/
|
|
9
|
-
get currentStep() {
|
|
10
|
-
return this.state.step;
|
|
11
|
-
}
|
|
12
|
-
constructor(plan) {
|
|
13
|
-
this.state = new StateMachine(plan);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Asserts the current step is `step`.
|
|
17
|
-
* @param step expected step.
|
|
18
|
-
*/
|
|
19
|
-
is(step) {
|
|
20
|
-
this.assert('is', step);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Asserts the current step is not `step`.
|
|
24
|
-
* @param step not expected step.
|
|
25
|
-
*/
|
|
26
|
-
not(step) {
|
|
27
|
-
if (this.state.isValid(step)) {
|
|
28
|
-
throw new InvalidOrder(this.state.get(), 'not', this.not, step);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Reset to specified step.
|
|
33
|
-
*/
|
|
34
|
-
jump(step) {
|
|
35
|
-
this.state.jump(step);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Move to next step.
|
|
39
|
-
*/
|
|
40
|
-
move() {
|
|
41
|
-
this.state.move();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Asserts the specified step will run once.
|
|
45
|
-
*/
|
|
46
|
-
once(step) {
|
|
47
|
-
this.assert('once', step);
|
|
48
|
-
this.state.move();
|
|
49
|
-
}
|
|
50
|
-
on(step, assert) {
|
|
51
|
-
this.state.on(step, () => {
|
|
52
|
-
assert(step);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
atLeastOnce(step) {
|
|
56
|
-
const nextStep = step + 1;
|
|
57
|
-
if (this.state.step === step) {
|
|
58
|
-
this.state.move();
|
|
59
|
-
return this.state.moveSubStep();
|
|
60
|
-
}
|
|
61
|
-
else if (this.state.step === nextStep && this.state.subStep > 0) {
|
|
62
|
-
return this.state.moveSubStep();
|
|
63
|
-
}
|
|
64
|
-
else
|
|
65
|
-
throw new InvalidOrder(this.state.get(), 'atLeastOnce', this.atLeastOnce, step);
|
|
66
|
-
}
|
|
67
|
-
any(steps) {
|
|
68
|
-
const index = steps.indexOf(this.state.step);
|
|
69
|
-
if (index === -1)
|
|
70
|
-
throw new InvalidOrder(this.state.get(), 'any', this.any, steps);
|
|
71
|
-
this.state.move();
|
|
72
|
-
return steps[index];
|
|
73
|
-
}
|
|
74
|
-
onAny(steps, ...asserts) {
|
|
75
|
-
steps.forEach(step => {
|
|
76
|
-
this.state.on(step, () => {
|
|
77
|
-
let firstError;
|
|
78
|
-
let hasPass = false;
|
|
79
|
-
asserts.forEach(assert => {
|
|
80
|
-
try {
|
|
81
|
-
assert(step);
|
|
82
|
-
hasPass = true;
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
if (!firstError)
|
|
86
|
-
firstError = err;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
if (!hasPass)
|
|
90
|
-
throw firstError;
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
end(timeout) {
|
|
96
|
-
if (timeout) {
|
|
97
|
-
return new Promise(r => {
|
|
98
|
-
setTimeout(r, timeout);
|
|
99
|
-
}).then(() => {
|
|
100
|
-
return this.end();
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (!this.state.isMaxStepDefined()) {
|
|
104
|
-
this.state.stopAccepting();
|
|
105
|
-
return this.state.getTimeTaken();
|
|
106
|
-
}
|
|
107
|
-
if (this.state.isAccepting()) {
|
|
108
|
-
throw new InvalidOrder(this.state.get(), 'end', this.end);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exactly(step, times) {
|
|
112
|
-
if (this.state.isNotValid(step))
|
|
113
|
-
throw new InvalidOrder(this.state.get(), 'exactly', this.exactly, step, times);
|
|
114
|
-
if (this.state.maxSubStep === undefined) {
|
|
115
|
-
this.state.maxSubStep = times;
|
|
116
|
-
this.state.minSubStep = times;
|
|
117
|
-
}
|
|
118
|
-
return this.state.moveSubStep();
|
|
119
|
-
}
|
|
120
|
-
wait(step, callback) {
|
|
121
|
-
if (callback)
|
|
122
|
-
this.on(step, callback);
|
|
123
|
-
else
|
|
124
|
-
return new Promise(a => { this.on(step, a); });
|
|
125
|
-
}
|
|
126
|
-
assert(method, step) {
|
|
127
|
-
if (this.state.isNotValid(step)) {
|
|
128
|
-
throw new InvalidOrder(this.state.get(), method, this[method], step);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=AssertOrder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AssertOrder.js","sourceRoot":"","sources":["../../src/assert-order/AssertOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,+EAA+E;AAC/E,4EAA4E;AAE5E,MAAM,OAAO,WAAW;IACtB;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;IAGD,YAAY,IAAa;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;;OAGG;IACH,EAAE,CAAC,IAAY;QACb,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACzB,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,IAAY;QACd,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC5B,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;SAChE;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;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C,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;SAC1D;IACH,CAAC;IACD,OAAO,CAAC,IAAY,EAAE,KAAa;QACjC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;YAC7B,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;QAEhF,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAA;YAC7B,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAA;SAC9B;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAA;IACjC,CAAC;IAGD,IAAI,CAAC,IAAY,EAAE,QAAqB;QACtC,IAAI,QAAQ;YACV,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;;YAEvB,OAAO,IAAI,OAAO,CAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC;IACO,MAAM,CAAC,MAAc,EAAE,IAAY;QACzC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAC/B,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAA;SACrE;IACH,CAAC;CACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import AssertionError from 'assertion-error';
|
|
2
|
-
import { State } from './interfaces';
|
|
3
|
-
export declare class InvalidOrder extends AssertionError {
|
|
4
|
-
method: string;
|
|
5
|
-
args: any[];
|
|
6
|
-
state: State;
|
|
7
|
-
constructor(state: State, method: string, ssf: Function, ...args: any[]);
|
|
8
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import AssertionError from 'assertion-error';
|
|
2
|
-
export class InvalidOrder extends AssertionError {
|
|
3
|
-
constructor(state, method, ssf, ...args) {
|
|
4
|
-
const message = method === 'end' ? getEndMessage(state) : getExpectingMessage(state, method, args);
|
|
5
|
-
super(message, { method, state, args }, ssf);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
function getEndMessage(state) {
|
|
9
|
-
return `Planned for ${state.maxStep} step but expecting step ${state.step} when 'end()' is called`;
|
|
10
|
-
}
|
|
11
|
-
function getExpectingMessage(state, method, args) {
|
|
12
|
-
return `Expecting ${getExpectingCalls(state)}, but received '${method}(${getMethodArgs(args)})'`;
|
|
13
|
-
}
|
|
14
|
-
function getExpectingCalls(state) {
|
|
15
|
-
let message;
|
|
16
|
-
if (state.subStep === 0) {
|
|
17
|
-
const methods = ['is', 'once', 'any'];
|
|
18
|
-
message = methods.map(m => ['any'].indexOf(m) === -1 ?
|
|
19
|
-
`'${m}(${state.step})'` :
|
|
20
|
-
`'${m}([${state.step}])'`).join(', ');
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const methods = ['exactly'];
|
|
24
|
-
message = methods.map(m => `'${m}(${state.step}, ${state.maxSubStep})'`).join(', ');
|
|
25
|
-
}
|
|
26
|
-
return message;
|
|
27
|
-
}
|
|
28
|
-
function getMethodArgs(args) {
|
|
29
|
-
return args.map(a => Array.isArray(a) ? `[${a.join(', ')}]` : a).join(', ');
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=InvalidOrder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidOrder.js","sourceRoot":"","sources":["../../src/assert-order/InvalidOrder.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,iBAAiB,CAAC;AA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AC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACpF;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,IAAW;IAChC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { State } from './interfaces';
|
|
2
|
-
export declare class StateMachine {
|
|
3
|
-
listeners: {};
|
|
4
|
-
step: number;
|
|
5
|
-
maxStep?: number;
|
|
6
|
-
subStep: number;
|
|
7
|
-
minSubStep?: number;
|
|
8
|
-
maxSubStep?: number;
|
|
9
|
-
private startTick;
|
|
10
|
-
constructor(maxStep?: number);
|
|
11
|
-
jump(step: number): number;
|
|
12
|
-
move(): number;
|
|
13
|
-
moveSubStep(): number;
|
|
14
|
-
get(): State;
|
|
15
|
-
on(step: number, listener: any): void;
|
|
16
|
-
isNotValid(step: number): boolean;
|
|
17
|
-
isValid(step: number): boolean;
|
|
18
|
-
isMaxStepDefined(): boolean;
|
|
19
|
-
stopAccepting(): void;
|
|
20
|
-
isAccepting(): boolean;
|
|
21
|
-
getTimeTaken(): any;
|
|
22
|
-
private getStartTick;
|
|
23
|
-
}
|