@@ -241,34 +241,96 @@ function checkRestCrudContents() {
241241 assert . fileContent ( expectedFile , / b a r R e p o s i t o r y \: B a r R e p o s i t o r y / ) ;
242242
243243 // Assert that the decorators are present in the correct groupings!
244- assert . fileContent (
245- expectedFile ,
246- / \@ p o s t \( ' \/ p r o d u c t - r e v i e w s ' \) \s { 1 , } a s y n c c r e a t e \( \@ r e q u e s t B o d y \( \) / ,
247- ) ;
248- assert . fileContent (
249- expectedFile ,
250- / \@ g e t \( ' \/ p r o d u c t - r e v i e w s \/ c o u n t ' \) \s { 1 , } a s y n c c o u n t \( \@ p a r a m .q u e r y .s t r i n g \( ' w h e r e ' \) / ,
251- ) ;
252- assert . fileContent (
253- expectedFile ,
254- / \@ g e t \( ' \/ p r o d u c t - r e v i e w s ' \) \s { 1 , } a s y n c f i n d \( \@ p a r a m .q u e r y .s t r i n g \( ' f i l t e r ' \) / ,
255- ) ;
256- assert . fileContent (
257- expectedFile ,
258- / \@ p a t c h \( ' \/ p r o d u c t - r e v i e w s ' \) \s { 1 , } a s y n c u p d a t e A l l \( \s { 1 , } \@ r e q u e s t B o d y \( \) .* , \s { 1 , } \@ p a r a m .q u e r y .s t r i n g \( ' w h e r e ' \) w h e r e \? : W h e r e / ,
259- ) ;
260- assert . fileContent (
261- expectedFile ,
262- / \@ g e t \( ' \/ p r o d u c t - r e v i e w s \/ { id} ' \) \s { 1 , } a s y n c f i n d B y I d \( \@ p a r a m .p a t h .n u m b e r \( ' i d ' \) / ,
263- ) ;
264- assert . fileContent (
265- expectedFile ,
266- / \@ p a t c h \( ' \/ p r o d u c t - r e v i e w s \/ { id} ' \) \s { 1 , } a s y n c u p d a t e B y I d \( \s { 1 , } \@ p a r a m .p a t h .n u m b e r \( ' i d ' \) i d : n u m b e r , \s { 1 , } \@ r e q u e s t B o d y \( \) / ,
267- ) ;
268- assert . fileContent (
269- expectedFile ,
270- / \@ d e l \( ' \/ p r o d u c t - r e v i e w s \/ { id} ' \) \s { 1 , } a s y n c d e l e t e B y I d \( \@ p a r a m .p a t h .n u m b e r \( ' i d ' \) i d : n u m b e r \) / ,
271- ) ;
244+ // @post - create
245+ const postCreateRegEx = [
246+ / \@ p o s t \( ' \/ p r o d u c t - r e v i e w s ' , { / ,
247+ / r e s p o n s e s : { / ,
248+ / ' 2 0 0 ' : { / ,
249+ / d e s c r i p t i o n : ' P r o d u c t R e v i e w m o d e l i n s t a n c e ' / ,
250+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : P r o d u c t R e v i e w } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
251+ / a s y n c c r e a t e \( \@ r e q u e s t B o d y \( \) / ,
252+ ] ;
253+ postCreateRegEx . forEach ( regex => {
254+ assert . fileContent ( expectedFile , regex ) ;
255+ } ) ;
256+
257+ // @get - count
258+ const getCountRegEx = [
259+ / \@ g e t \( ' \/ p r o d u c t - r e v i e w s \/ c o u n t ' , { / ,
260+ / r e s p o n s e s : { / ,
261+ / ' 2 0 0 ' : { / ,
262+ / d e s c r i p t i o n : ' P r o d u c t R e v i e w m o d e l c o u n t ' / ,
263+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : N u m b e r } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
264+ / a s y n c c o u n t \( \@ p a r a m .q u e r y .s t r i n g \( ' w h e r e ' \) / ,
265+ ] ;
266+ getCountRegEx . forEach ( regex => {
267+ assert . fileContent ( expectedFile , regex ) ;
268+ } ) ;
269+
270+ // @get - find
271+ const getFindRegEx = [
272+ / \@ g e t \( ' \/ p r o d u c t - r e v i e w s ' , { / ,
273+ / r e s p o n s e s : { / ,
274+ / ' 2 0 0 ' : { / ,
275+ / d e s c r i p t i o n : ' A r r a y o f P r o d u c t R e v i e w m o d e l i n s t a n c e s ' / ,
276+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : P r o d u c t R e v i e w } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
277+ / a s y n c f i n d \( \@ p a r a m .q u e r y .s t r i n g \( ' f i l t e r ' \) / ,
278+ ] ;
279+ getFindRegEx . forEach ( regex => {
280+ assert . fileContent ( expectedFile , regex ) ;
281+ } ) ;
282+
283+ // @patch - updateAll
284+ const patchUpdateAllRegEx = [
285+ / \@ p a t c h \( ' \/ p r o d u c t - r e v i e w s ' , { / ,
286+ / r e s p o n s e s : { / ,
287+ / ' 2 0 0 ' : { / ,
288+ / d e s c r i p t i o n : ' P r o d u c t R e v i e w P A T C H s u c c e s s c o u n t ' / ,
289+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : N u m b e r } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
290+ / a s y n c u p d a t e A l l \( \s { 1 , } \@ r e q u e s t B o d y \( \) .* , \s { 1 , } \@ p a r a m .q u e r y .s t r i n g \( ' w h e r e ' \) w h e r e \? : W h e r e / ,
291+ ] ;
292+ patchUpdateAllRegEx . forEach ( regex => {
293+ assert . fileContent ( expectedFile , regex ) ;
294+ } ) ;
295+
296+ // @get - findById
297+ const getFindByIdRegEx = [
298+ / \@ g e t \( ' \/ p r o d u c t - r e v i e w s \/ { id} ' , { / ,
299+ / r e s p o n s e s : { / ,
300+ / ' 2 0 0 ' : { / ,
301+ / d e s c r i p t i o n : ' P r o d u c t R e v i e w m o d e l i n s t a n c e ' / ,
302+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : P r o d u c t R e v i e w } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
303+ / a s y n c f i n d B y I d \( \@ p a r a m .p a t h .n u m b e r \( ' i d ' \) / ,
304+ ] ;
305+ getFindByIdRegEx . forEach ( regex => {
306+ assert . fileContent ( expectedFile , regex ) ;
307+ } ) ;
308+
309+ // @patch - updateById
310+ const patchUpdateByIdRegEx = [
311+ / \@ p a t c h \( ' \/ p r o d u c t - r e v i e w s \/ { id} ' / ,
312+ / r e s p o n s e s : { / ,
313+ / ' 2 0 0 ' : { / ,
314+ / d e s c r i p t i o n : ' P r o d u c t R e v i e w P A T C H s u c c e s s ' / ,
315+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : B o o l e a n } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
316+ / a s y n c u p d a t e B y I d \( \s { 1 , } \@ p a r a m .p a t h .n u m b e r \( ' i d ' \) i d : n u m b e r , \s { 1 , } \@ r e q u e s t B o d y \( \) / ,
317+ ] ;
318+ patchUpdateByIdRegEx . forEach ( regex => {
319+ assert . fileContent ( expectedFile , regex ) ;
320+ } ) ;
321+
322+ // @del - deleteById
323+ const deleteByIdRegEx = [
324+ / \@ d e l \( ' \/ p r o d u c t - r e v i e w s \/ { id} ' , { / ,
325+ / r e s p o n s e s : { / ,
326+ / ' 2 0 0 ' : { / ,
327+ / d e s c r i p t i o n : ' P r o d u c t R e v i e w D E L E T E s u c c e s s ' / ,
328+ / c o n t e n t : { ' a p p l i c a t i o n \/ j s o n ' : { ' x - t s - t y p e ' : B o o l e a n } } , \s { 1 , } } , \s { 1 , } } , \s { 1 , } } \) / ,
329+ / a s y n c d e l e t e B y I d \( \@ p a r a m .p a t h .n u m b e r \( ' i d ' \) i d : n u m b e r \) / ,
330+ ] ;
331+ deleteByIdRegEx . forEach ( regex => {
332+ assert . fileContent ( expectedFile , regex ) ;
333+ } ) ;
272334}
273335
274336/**
@@ -278,30 +340,30 @@ function checkRestCrudContents() {
278340function checkRestPaths ( restUrl ) {
279341 assert . fileContent (
280342 expectedFile ,
281- new RegExp ( / @ p o s t \( ' / . source + restUrl + / ' \) / . source ) ,
343+ new RegExp ( / @ p o s t \( ' / . source + restUrl + / ' , { / . source ) ,
282344 ) ;
283345 assert . fileContent (
284346 expectedFile ,
285- new RegExp ( / @ g e t \( ' / . source + restUrl + / \/ c o u n t ' \) / . source ) ,
347+ new RegExp ( / @ g e t \( ' / . source + restUrl + / \/ c o u n t ' , { / . source ) ,
286348 ) ;
287349 assert . fileContent (
288350 expectedFile ,
289- new RegExp ( / @ g e t \( ' / . source + restUrl + / ' \) / . source ) ,
351+ new RegExp ( / @ g e t \( ' / . source + restUrl + / ' , { / . source ) ,
290352 ) ;
291353 assert . fileContent (
292354 expectedFile ,
293- new RegExp ( / @ p a t c h \( ' / . source + restUrl + / ' \) / . source ) ,
355+ new RegExp ( / @ p a t c h \( ' / . source + restUrl + / ' , { / . source ) ,
294356 ) ;
295357 assert . fileContent (
296358 expectedFile ,
297- new RegExp ( / @ g e t \( ' / . source + restUrl + / \/ { id} ' \) / . source ) ,
359+ new RegExp ( / @ g e t \( ' / . source + restUrl + / \/ { id} ' , { / . source ) ,
298360 ) ;
299361 assert . fileContent (
300362 expectedFile ,
301- new RegExp ( / @ p a t c h \( ' / . source + restUrl + / \/ { id} ' \) / . source ) ,
363+ new RegExp ( / @ p a t c h \( ' / . source + restUrl + / \/ { id} ' , { / . source ) ,
302364 ) ;
303365 assert . fileContent (
304366 expectedFile ,
305- new RegExp ( / @ d e l \( ' / . source + restUrl + / \/ { id} ' \) / . source ) ,
367+ new RegExp ( / @ d e l \( ' / . source + restUrl + / \/ { id} ' , { / . source ) ,
306368 ) ;
307369}
0 commit comments