@push.rocks/smartexpect
Version:
A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.
37 lines (32 loc) • 802 B
text/typescript
import { Assertion } from '../smartexpect.classes.assertion.js';
import type { TExecutionType } from '../types.js';
/**
* Namespace for boolean-specific matchers
*/
export class BooleanMatchers<M extends TExecutionType> {
constructor(private assertion: Assertion<boolean, M>) {}
toBeTrue() {
return this.assertion.customAssertion(
(v) => v === true,
`Expected value to be true`
);
}
toBeFalse() {
return this.assertion.customAssertion(
(v) => v === false,
`Expected value to be false`
);
}
toBeTruthy() {
return this.assertion.customAssertion(
(v) => Boolean(v),
`Expected value to be truthy`
);
}
toBeFalsy() {
return this.assertion.customAssertion(
(v) => !v,
`Expected value to be falsy`
);
}
}