36 lines
722 B
TypeScript
36 lines
722 B
TypeScript
import { Assertion } from '../smartexpect.classes.assertion.js';
|
|
|
|
/**
|
|
* Namespace for boolean-specific matchers
|
|
*/
|
|
export class BooleanMatchers {
|
|
constructor(private assertion: Assertion<boolean>) {}
|
|
|
|
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`
|
|
);
|
|
}
|
|
} |