@@ -96,4 +96,51 @@ describe('BoardController (e2e)', () => {
96
96
. get ( '/board/-1' )
97
97
. expect ( HttpStatus . NOT_FOUND ) ;
98
98
} ) ;
99
+
100
+ it ( '[GET] /board : Should return array of 5 objects since 7 boards are saved' , async ( ) => {
101
+ const savedUser = await saveBoards ( 7 ) ;
102
+ const result = await request ( app . getHttpServer ( ) ) . get (
103
+ '/board?page=0&size=5' ,
104
+ ) ;
105
+ expect ( result . status ) . toBe ( HttpStatus . OK ) ;
106
+ const response = result . body as BoardInfoResponseDto [ ] ;
107
+ expect ( response . length ) . toBe ( 5 ) ;
108
+ for ( const board of response ) {
109
+ expect ( typeof board . boardId ) . toBe ( 'number' ) ;
110
+ expect ( board . content ) . toContain ( CONTENT ) ;
111
+ expect ( board . createdAt ) . toBeDefined ( ) ;
112
+ expect ( board . lastModifiedAt ) . toBeDefined ( ) ;
113
+ expect ( board . name ) . toBe ( NAME ) ;
114
+ expect ( board . title ) . toContain ( TITLE ) ;
115
+ expect ( board . userId ) . toBe ( savedUser . getUser_id ) ;
116
+ }
117
+ } ) ;
118
+
119
+ it ( '[GET] /board: Should return array of 2 objects since 7 boards are saved' , async ( ) => {
120
+ const savedUser = await saveBoards ( 7 ) ;
121
+ const result = await request ( app . getHttpServer ( ) ) . get (
122
+ '/board?page=1&size=5' ,
123
+ ) ;
124
+ expect ( result . status ) . toBe ( HttpStatus . OK ) ;
125
+ const response = result . body as BoardInfoResponseDto [ ] ;
126
+ expect ( response . length ) . toBe ( 2 ) ;
127
+ for ( const board of response ) {
128
+ expect ( typeof board . boardId ) . toBe ( 'number' ) ;
129
+ expect ( board . content ) . toContain ( CONTENT ) ;
130
+ expect ( board . createdAt ) . toBeDefined ( ) ;
131
+ expect ( board . lastModifiedAt ) . toBeDefined ( ) ;
132
+ expect ( board . name ) . toBe ( NAME ) ;
133
+ expect ( board . title ) . toContain ( TITLE ) ;
134
+ expect ( board . userId ) . toBe ( savedUser . getUser_id ) ;
135
+ }
136
+ } ) ;
137
+
138
+ it ( '[GET] /board: Should return array of 0 objects since 0 boards are saved' , async ( ) => {
139
+ const result = await request ( app . getHttpServer ( ) ) . get (
140
+ '/board?page=0&size=5' ,
141
+ ) ;
142
+ expect ( result . status ) . toBe ( HttpStatus . OK ) ;
143
+ const response = result . body as BoardInfoResponseDto [ ] ;
144
+ expect ( response . length ) . toBe ( 0 ) ;
145
+ } ) ;
99
146
} ) ;
0 commit comments