Skip to content

Commit a751cdb

Browse files
committed
feat(assertions): add some more aliases; cleanup
chore(diff): cleanup
1 parent 1b9feb0 commit a751cdb

14 files changed

+353
-509
lines changed

site/assertions/collection.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ expect([1, 2, 3], 'not to be empty');
5858

5959
### `{array} to have length {nonnegative-integer}`
6060

61+
> ✏️ Aliases:
62+
>
63+
> {array} to have length {nonnegative-integer}
64+
> {array} to have size {nonnegative-integer}
65+
6166
**Success**:
6267

6368
```js

site/assertions/object.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ expect({ a: 1 }, 'not to be empty');
8989
> {object} to have keys {array}
9090
> {object} to have properties {array}
9191
> {object} to have props {array}
92+
> {object} to include keys {array}
93+
> {object} to include properties {array}
94+
> {object} to include props {array}
95+
> {object} to contain keys {array}
96+
> {object} to contain properties {array}
97+
> {object} to contain props {array}
9298
9399
**Success**:
94100

@@ -117,6 +123,12 @@ expect({ a: 1 }, 'not to have keys', ['a', 'b']);
117123
> {object} to have key {keypath}
118124
> {object} to have property {keypath}
119125
> {object} to have prop {keypath}
126+
> {object} to include key {keypath}
127+
> {object} to include property {keypath}
128+
> {object} to include prop {keypath}
129+
> {object} to contain key {keypath}
130+
> {object} to contain property {keypath}
131+
> {object} to contain prop {keypath}
120132
121133
Tests whether an object has a property at the specified keypath using dot or bracket notation. This assertion supports complex _keypath_ traversal including nested properties, array indices, and quoted keys.
122134

src/assertion/impl/async-parametric.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ export const functionResolveAssertion = createAsyncAssertion(
5151
await subject();
5252
} catch {
5353
return {
54-
actual: 'function rejected',
55-
expected: 'function to fulfill',
5654
message: 'Expected function to fulfill, but it rejected instead',
5755
};
5856
}
@@ -67,18 +65,11 @@ export const functionResolveAssertion = createAsyncAssertion(
6765
* ```typescript
6866
* await expectAsync(Promise.resolve('success'), 'to resolve'); // passes
6967
* await expectAsync(Promise.reject('error'), 'to fulfill'); // fails
70-
* /**
71-
* Assertion for testing if a promise resolves.
72-
*
73-
* @example
74-
*
75-
* ```typescript
76-
* await expectAsync(Promise.resolve('success'), 'to resolve'); // passes
77-
* await expectAsync(Promise.reject('error'), 'to resolve'); // fails
7868
* ```
7969
*
80-
* @group Parametric Assertions (Async) @bupkisAnchor promise-to-resolve
8170
* @bupkisAssertionCategory promise
71+
* @bupkisAnchor promise-to-resolve
72+
* @group Parametric Assertions (Async)
8273
*/
8374
export const promiseResolveAssertion = createAsyncAssertion(
8475
[WrappedPromiseLikeSchema, ['to resolve', 'to fulfill']],
@@ -87,8 +78,6 @@ export const promiseResolveAssertion = createAsyncAssertion(
8778
await subject;
8879
} catch {
8980
return {
90-
actual: 'promise rejected',
91-
expected: 'promise to fulfill',
9281
message: 'Expected promise to fulfill, but it rejected instead',
9382
};
9483
}
@@ -113,8 +102,6 @@ export const functionRejectAssertion = createAsyncAssertion(
113102
const { error, result } = await trapAsyncFnError(subject);
114103
if (error === undefined) {
115104
return {
116-
actual: 'function fulfilled',
117-
expected: 'function rejected',
118105
message: `Expected function to reject, but it fulfilled with ${inspect(result)}`,
119106
};
120107
}
@@ -139,8 +126,6 @@ export const promiseRejectAssertion = createAsyncAssertion(
139126
const { error, result } = await trapPromiseError(subject);
140127
if (error === undefined) {
141128
return {
142-
actual: 'Promise fulfilled',
143-
expected: 'Promise rejected',
144129
message: `Expected Promise to reject, but it fulfilled with ${inspect(result)}`,
145130
};
146131
}

0 commit comments

Comments
 (0)