@@ -17,7 +17,7 @@ describe('Versions API', () => {
1717 let versionsRepository ;
1818 const FETCH_DATE = new Date ( '2023-01-01T12:00:00Z' ) ;
1919 const VERSION_COMMON_ATTRIBUTES = {
20- serviceId : 'service-1 ' ,
20+ serviceId : 'service·A ' ,
2121 termsType : 'Terms of Service' ,
2222 snapshotId : [ 'snapshot_id' ] ,
2323 } ;
@@ -62,7 +62,7 @@ describe('Versions API', () => {
6262
6363 context ( 'when a version is found' , ( ) => {
6464 before ( async ( ) => {
65- response = await request . get ( `${ basePath } /v1/version/service-1 /Terms%20of%20Service/${ encodeURIComponent ( toISODateWithoutMilliseconds ( FETCH_DATE ) ) } ` ) ;
65+ response = await request . get ( `${ basePath } /v1/version/service·A /Terms%20of%20Service/${ encodeURIComponent ( toISODateWithoutMilliseconds ( FETCH_DATE ) ) } ` ) ;
6666 } ) ;
6767
6868 it ( 'responds with 200 status code' , ( ) => {
@@ -80,7 +80,7 @@ describe('Versions API', () => {
8080
8181 context ( 'when the requested date is anterior to the first available version' , ( ) => {
8282 before ( async ( ) => {
83- response = await request . get ( `${ basePath } /v1/version/service-1 /Terms%20of%20Service/2000-01-01T12:00:00Z` ) ;
83+ response = await request . get ( `${ basePath } /v1/version/service·A /Terms%20of%20Service/2000-01-01T12:00:00Z` ) ;
8484 } ) ;
8585
8686 it ( 'responds with 404 status code' , ( ) => {
@@ -96,11 +96,36 @@ describe('Versions API', () => {
9696 } ) ;
9797 } ) ;
9898
99+ context ( 'when the serviceId uses different casing' , ( ) => {
100+ before ( async ( ) => {
101+ response = await request . get ( `${ basePath } /v1/version/SERVICE·A/Terms%20of%20Service/${ encodeURIComponent ( toISODateWithoutMilliseconds ( FETCH_DATE ) ) } ` ) ;
102+ } ) ;
103+
104+ it ( 'still resolves to the service (case-insensitive)' , ( ) => {
105+ expect ( response . status ) . to . equal ( 200 ) ;
106+ expect ( response . body ) . to . deep . equal ( expectedResult ) ;
107+ } ) ;
108+ } ) ;
109+
110+ context ( 'when the service does not exist' , ( ) => {
111+ before ( async ( ) => {
112+ response = await request . get ( `${ basePath } /v1/version/DoesNotExist/Terms%20of%20Service/${ encodeURIComponent ( toISODateWithoutMilliseconds ( FETCH_DATE ) ) } ` ) ;
113+ } ) ;
114+
115+ it ( 'responds with 404 status code' , ( ) => {
116+ expect ( response . status ) . to . equal ( 404 ) ;
117+ } ) ;
118+
119+ it ( 'returns an error message' , ( ) => {
120+ expect ( response . body . error ) . to . equal ( 'Service not found' ) ;
121+ } ) ;
122+ } ) ;
123+
99124 context ( 'when the requested date is in the future' , ( ) => {
100125 before ( async ( ) => {
101126 const dateInTheFuture = new Date ( Date . now ( ) + 60000 ) ; // 1 minute in the future
102127
103- response = await request . get ( `${ basePath } /v1/version/service-1 /Terms%20of%20Service/${ encodeURIComponent ( toISODateWithoutMilliseconds ( dateInTheFuture ) ) } ` ) ;
128+ response = await request . get ( `${ basePath } /v1/version/service·A /Terms%20of%20Service/${ encodeURIComponent ( toISODateWithoutMilliseconds ( dateInTheFuture ) ) } ` ) ;
104129 } ) ;
105130
106131 it ( 'responds with 416 status code' , ( ) => {
0 commit comments