@@ -132,15 +132,6 @@ describe('Accessible Records Plugin', () => {
132132 } )
133133 } )
134134
135- it ( 'throws `ForbiddenError` when callback is passed to `exec`' , async ( ) => {
136- await wrapInPromise ( cb => query . exec ( cb ) )
137- . then ( ( ) => fail ( 'should not execute' ) )
138- . catch ( ( error : any ) => {
139- expect ( error ) . toBeInstanceOf ( ForbiddenError )
140- expect ( error . message ) . toMatch ( / c a n n o t e x e c u t e / i)
141- } )
142- } )
143-
144135 it ( 'throws `ForbiddenError` for item request' , async ( ) => {
145136 await query . findOne ( ) . exec ( )
146137 . then ( ( ) => fail ( 'should not execute' ) )
@@ -159,15 +150,6 @@ describe('Accessible Records Plugin', () => {
159150 } )
160151 } )
161152
162- it ( 'throws `ForbiddenError` for item request when callback is passed to `exec`' , async ( ) => {
163- await wrapInPromise ( cb => query . findOne ( ) . exec ( cb ) )
164- . then ( ( ) => fail ( 'should not execute' ) )
165- . catch ( ( error : any ) => {
166- expect ( error ) . toBeInstanceOf ( ForbiddenError )
167- expect ( error . message ) . toMatch ( / c a n n o t e x e c u t e / i)
168- } )
169- } )
170-
171153 it ( 'throws `ForbiddenError` for count request' , async ( ) => {
172154 await query . count ( )
173155 . then ( ( ) => fail ( 'should not execute' ) )
@@ -208,7 +190,7 @@ describe('Accessible Records Plugin', () => {
208190 const anotherAbility = createMongoAbility ( [
209191 { action : 'read' , subject : Post }
210192 ] , {
211- detectSubjectType : o => o . constructor ,
193+ detectSubjectType : o => o . constructor as SubjectType ,
212194 } )
213195
214196 await Post . find ( ) . accessibleBy ( anotherAbility , 'update' )
@@ -220,11 +202,4 @@ describe('Accessible Records Plugin', () => {
220202 } )
221203 } )
222204 } )
223-
224- type Callback = ( err : mongoose . CallbackError , result : unknown ) => void
225- function wrapInPromise ( callback : ( fn : Callback ) => void ) {
226- return new Promise ( ( resolve , reject ) => {
227- callback ( ( error , result ) => error ? reject ( error ) : resolve ( result ) )
228- } )
229- }
230205} )
0 commit comments