File tree Expand file tree Collapse file tree 2 files changed +48
-9
lines changed Expand file tree Collapse file tree 2 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,28 @@ describe("User Controller", () => {
3838 provide : UserService ,
3939 useValue : {
4040 create : jest . fn ( ) . mockResolvedValue ( createUserDto ) ,
41+ findAll : jest . fn ( ) . mockResolvedValue ( [
42+ {
43+ username : "1sss1" ,
44+ first_name : "test" ,
45+ last_name : "test" ,
46+ password : "Sairam1@" ,
47+ password_reset_code : "1" ,
48+ email : "te@test.com" ,
49+ email_code : "eee" ,
50+ activation_code : "e" ,
51+ } ,
52+ {
53+ username : "test" ,
54+ first_name : "test" ,
55+ last_name : "test" ,
56+ password : "Sairam1@" ,
57+ password_reset_code : "1" ,
58+ email : "te@test.com" ,
59+ email_code : "eee" ,
60+ activation_code : "e" ,
61+ }
62+ ] ) ,
4163 } ,
4264 } ,
4365 ] ,
@@ -57,5 +79,31 @@ describe("User Controller", () => {
5779 await controller . create ( createUserDto , response ) ;
5880 expect ( createSpy ) . toHaveBeenCalledWith ( createUserDto ) ;
5981 } ) ;
82+
83+ it ( 'should return an array of users' , async ( ) => {
84+ expect ( controller . findAll ( ) ) . resolves . toEqual ( [
85+ {
86+ username : "1sss1" ,
87+ first_name : "test" ,
88+ last_name : "test" ,
89+ password : "Sairam1@" ,
90+ password_reset_code : "1" ,
91+ email : "te@test.com" ,
92+ email_code : "eee" ,
93+ activation_code : "e" ,
94+ } ,
95+ {
96+ username : "test" ,
97+ first_name : "test" ,
98+ last_name : "test" ,
99+ password : "Sairam1@" ,
100+ password_reset_code : "1" ,
101+ email : "te@test.com" ,
102+ email_code : "eee" ,
103+ activation_code : "e" ,
104+ }
105+ ] ) ;
106+ expect ( service . findAll ) . toHaveBeenCalled ( ) ;
107+ } ) ;
60108 } ) ;
61109} ) ;
Original file line number Diff line number Diff line change @@ -27,13 +27,4 @@ export class UserController {
2727 return this . userService . findAll ( ) ;
2828 }
2929
30- @Get ( ":id" )
31- async findOne ( @Param ( "id" ) id : string ) : Promise < userData > {
32- return this . userService . findOne ( id ) ;
33- }
34-
35- @Delete ( ":id" )
36- async delete ( @Param ( "id" ) id : string ) {
37- return this . userService . delete ( id ) ;
38- }
3930}
You can’t perform that action at this time.
0 commit comments