File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -199,10 +199,9 @@ describe('ReciterService', () => {
199
199
200
200
it ( 'should throw NotFoundException if tilawa not found' , async ( ) => {
201
201
jest . spyOn ( tilawaRepository , 'findOneBy' ) . mockResolvedValueOnce ( null ) ;
202
+ const result = service . getReciterTilawaId ( 1 ) ;
202
203
203
- await expect ( service . getReciterTilawaId ( 1 ) ) . rejects . toThrow (
204
- NotFoundException ,
205
- ) ;
204
+ expect ( result ) . rejects . toThrow ( NotFoundException ) ;
206
205
} ) ;
207
206
} ) ;
208
207
@@ -224,10 +223,8 @@ describe('ReciterService', () => {
224
223
225
224
it ( 'should throw NotFoundException if no tilawas found' , async ( ) => {
226
225
jest . spyOn ( tilawaRepository , 'find' ) . mockResolvedValue ( [ ] ) ;
227
-
228
- await expect ( service . getReciterTilawa ( 1 ) ) . rejects . toThrow (
229
- NotFoundException ,
230
- ) ;
226
+ const result = service . getReciterTilawa ( 1 ) ;
227
+ await expect ( result ) . rejects . toThrow ( NotFoundException ) ;
231
228
} ) ;
232
229
} ) ;
233
230
Original file line number Diff line number Diff line change @@ -76,15 +76,15 @@ export class ReciterService {
76
76
const tilawa = await this . tilawaRepository . find ( {
77
77
where : { reciter_id : reciterId } ,
78
78
} ) ;
79
-
80
- if ( ! tilawa ) throw new NotFoundException ( 'Tilawa not found' ) ;
81
-
79
+ if ( ! tilawa . length ) throw new NotFoundException ( 'Tilawa not found' ) ;
82
80
return tilawa ;
83
81
}
84
82
85
- addReciterTilawa ( id : number , addTilawaDto : AddTilawaDto ) {
86
- const tilawa = this . tilawaRepository . create ( addTilawaDto ) ;
87
- tilawa . reciter_id = id ;
83
+ addReciterTilawa ( id : number , addTilawaDto : Omit < AddTilawaDto , 'reciter_id' > ) {
84
+ const tilawa = this . tilawaRepository . create ( {
85
+ ...addTilawaDto ,
86
+ reciter_id : id ,
87
+ } ) ;
88
88
return this . tilawaRepository . save ( tilawa ) ;
89
89
}
90
90
}
You can’t perform that action at this time.
0 commit comments