Commit 96e6070 1 parent a0ec42d commit 96e6070 Copy full SHA for 96e6070
File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ declare module 'bun:test' {
103
103
interface Matchers {
104
104
/** Asserts that a value is a plain `object`. */
105
105
toBePlainObject ( ) : void ;
106
+ /** Asserts that a value is a `class`. */
107
+ toBeClass ( ) : void ;
106
108
/** Asserts that a function has a specific number of parameters. */
107
109
toHaveParameters ( required : number , optional : number ) : void ;
108
110
}
@@ -119,6 +121,16 @@ expect.extend({
119
121
} ;
120
122
} ,
121
123
124
+ toBeClass ( received : unknown ) {
125
+ return typeof received === 'function' &&
126
+ / ^ c l a s s \s / . test ( Function . prototype . toString . call ( received ) )
127
+ ? { pass : true }
128
+ : {
129
+ pass : false ,
130
+ message : ( ) => `expected ${ String ( received ) } to be a class` ,
131
+ } ;
132
+ } ,
133
+
122
134
toHaveParameters ( received : unknown , required : number , optional : number ) {
123
135
if ( typeof received !== 'function' ) {
124
136
return {
You can’t perform that action at this time.
0 commit comments