@@ -12,10 +12,7 @@ import { AgencyRepositoryMock } from "test/agency/agency.repository.mock";
1212import { AgencyBudgetRepositoryMock } from "test/agency-budget/agency-budget.repository.mock" ;
1313import * as request from "supertest" ;
1414import { HttpName } from "src/filter" ;
15- import {
16- DataRetrievalException ,
17- InvalidRequestParameterException ,
18- } from "src/exception" ;
15+ import { DataRetrievalException } from "src/exception" ;
1916import {
2017 findCapitalCommitmentsByManagingCodeCapitalProjectIdQueryResponseSchema ,
2118 findCapitalProjectByManagingCodeCapitalProjectIdQueryResponseSchema ,
@@ -122,49 +119,39 @@ describe("Capital Projects", () => {
122119 `/capital-projects?agencyBudget=${ agencyBudgetCode } ` ,
123120 ) ;
124121
125- expect ( response . body . message ) . toBe (
126- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
127- ) ;
122+ expect ( response . body . message ) . toMatch ( / c o u l d n o t c h e c k / ) ;
128123 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
129124 } ) ;
130125
131126 it ( "should 400 when finding by an invalid limit" , async ( ) => {
132127 const response = await request ( app . getHttpServer ( ) ) . get (
133128 "/capital-projects?limit=b4d" ,
134129 ) ;
135- expect ( response . body . message ) . toBe (
136- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
137- ) ;
130+ expect ( response . body . message ) . toMatch ( / l i m i t : E x p e c t e d n u m b e r / ) ;
138131 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
139132 } ) ;
140133
141134 it ( "should 400 when finding by a 'too-high' limit" , async ( ) => {
142135 const response = await request ( app . getHttpServer ( ) ) . get (
143136 "/capital-projects?limit=101" ,
144137 ) ;
145- expect ( response . body . message ) . toBe (
146- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
147- ) ;
138+ expect ( response . body . message ) . toMatch ( / l i m i t : N u m b e r m u s t b e l e s s / ) ;
148139 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
149140 } ) ;
150141
151142 it ( "should 400 when finding by a 'too-low' limit" , async ( ) => {
152143 const response = await request ( app . getHttpServer ( ) ) . get (
153144 "/capital-projects?limit=0" ,
154145 ) ;
155- expect ( response . body . message ) . toBe (
156- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
157- ) ;
146+ expect ( response . body . message ) . toMatch ( / l i m i t : N u m b e r m u s t b e g r e a t e r / ) ;
158147 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
159148 } ) ;
160149
161150 it ( "should 400 when finding by invalid offset" , async ( ) => {
162151 const response = await request ( app . getHttpServer ( ) ) . get (
163152 "/capital-projects?offset=b4d" ,
164153 ) ;
165- expect ( response . body . message ) . toBe (
166- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
167- ) ;
154+ expect ( response . body . message ) . toMatch ( / o f f s e t : E x p e c t e d n u m b e r / ) ;
168155 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
169156 } ) ;
170157
@@ -192,9 +179,7 @@ describe("Capital Projects", () => {
192179 const response = await request ( app . getHttpServer ( ) ) . get (
193180 `/capital-projects?cityCouncilDistrictId=${ id } ` ,
194181 ) ;
195- expect ( response . body . message ) . toBe (
196- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
197- ) ;
182+ expect ( response . body . message ) . toMatch ( / c i t y C o u n c i l D i s t r i c t I d : I n v a l i d / ) ;
198183 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
199184 } ) ;
200185
@@ -222,9 +207,7 @@ describe("Capital Projects", () => {
222207 const response = await request ( app . getHttpServer ( ) ) . get (
223208 `/capital-projects?communityDistrictId=${ id } ` ,
224209 ) ;
225- expect ( response . body . message ) . toBe (
226- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
227- ) ;
210+ expect ( response . body . message ) . toMatch ( / c o m m u n i t y D i s t r i c t I d : I n v a l i d / ) ;
228211 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
229212 } ) ;
230213
@@ -253,9 +236,7 @@ describe("Capital Projects", () => {
253236 const response = await request ( app . getHttpServer ( ) ) . get (
254237 `/capital-projects?managingAgency=${ managingAgency } ` ,
255238 ) ;
256- expect ( response . body . message ) . toBe (
257- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
258- ) ;
239+ expect ( response . body . message ) . toMatch ( / c o u l d n o t c h e c k / ) ;
259240 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
260241 } ) ;
261242
@@ -283,9 +264,7 @@ describe("Capital Projects", () => {
283264 const response = await request ( app . getHttpServer ( ) ) . get (
284265 `/capital-projects?commitmentsTotalMin=${ commitmentsTotalMin } ` ,
285266 ) ;
286- expect ( response . body . message ) . toBe (
287- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
288- ) ;
267+ expect ( response . body . message ) . toMatch ( / c o m m i t m e n t s T o t a l M i n : I n v a l i d / ) ;
289268 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
290269 } ) ;
291270
@@ -313,9 +292,7 @@ describe("Capital Projects", () => {
313292 const response = await request ( app . getHttpServer ( ) ) . get (
314293 `/capital-projects?commitmentsTotalMax=${ commitmentsTotalMax } ` ,
315294 ) ;
316- expect ( response . body . message ) . toBe (
317- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
318- ) ;
295+ expect ( response . body . message ) . toMatch ( / c o m m i t m e n t s T o t a l M a x : I n v a l i d / ) ;
319296 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
320297 } ) ;
321298
@@ -325,9 +302,7 @@ describe("Capital Projects", () => {
325302 const response = await request ( app . getHttpServer ( ) ) . get (
326303 `/capital-projects?commitmentsTotalMin=${ commitmentsTotalMin } &commitmentsTotalMax=${ commitmentsTotalMax } ` ,
327304 ) ;
328- expect ( response . body . message ) . toBe (
329- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
330- ) ;
305+ expect ( response . body . message ) . toMatch ( / m i n a m o u n t s h o u l d b e / ) ;
331306 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
332307 } ) ;
333308
@@ -407,18 +382,16 @@ describe("Capital Projects", () => {
407382 const response = await request ( app . getHttpServer ( ) ) . get (
408383 `/capital-projects?isMapped=123` ,
409384 ) ;
410- expect ( response . body . message ) . toBe (
411- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
412- ) ;
385+ expect ( response . body . message ) . toMatch ( / i n v a l i d v a l u e f o r b o o l e a n / ) ;
413386 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
414387 } ) ;
415388
416389 it ( "should 400 when when both a city council district id and isMapped are provided" , async ( ) => {
417390 const response = await request ( app . getHttpServer ( ) ) . get (
418391 `/capital-projects?cityCouncilDistrictId=50&isMapped=true` ,
419392 ) ;
420- expect ( response . body . message ) . toBe (
421- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
393+ expect ( response . body . message ) . toMatch (
394+ / c a n n o t h a v e i s M a p p e d f i l t e r i n c o n j u n c t i o n / ,
422395 ) ;
423396 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
424397 } ) ;
@@ -427,8 +400,8 @@ describe("Capital Projects", () => {
427400 const response = await request ( app . getHttpServer ( ) ) . get (
428401 `/capital-projects?communityDistrictId=101&isMapped=true` ,
429402 ) ;
430- expect ( response . body . message ) . toBe (
431- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
403+ expect ( response . body . message ) . toMatch (
404+ / c a n n o t h a v e i s M a p p e d f i l t e r i n c o n j u n c t i o n / ,
432405 ) ;
433406 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
434407 } ) ;
@@ -534,9 +507,6 @@ describe("Capital Projects", () => {
534507 )
535508 . expect ( 400 ) ;
536509
537- expect ( response . body . message ) . toBe (
538- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
539- ) ;
540510 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
541511 } ) ;
542512
@@ -609,9 +579,9 @@ describe("Capital Projects", () => {
609579 . get ( `/capital-projects/${ z } /${ x } /${ y } .pbf` )
610580 . expect ( 400 ) ;
611581
612- expect ( response . body . message ) . toBe (
613- new InvalidRequestParameterException ( "invalid parameters" ) . message ,
614- ) ;
582+ expect ( response . body . message ) . toMatch ( / z : E x p e c t e d n u m b e r / ) ;
583+ expect ( response . body . message ) . toMatch ( / x : E x p e c t e d n u m b e r / ) ;
584+ expect ( response . body . message ) . toMatch ( / y : E x p e c t e d n u m b e r / ) ;
615585
616586 expect ( response . body . error ) . toBe ( HttpName . BAD_REQUEST ) ;
617587 } ) ;
0 commit comments