37 lines
802 B
TypeScript
37 lines
802 B
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`
|
|
);
|
|
}
|
|
} |