11import * as assert from 'assert' ;
22import * as t from 'io-ts' ;
3- import { EncryptRequestBody , PostEncrypt } from '../../../src/typedRoutes/api/common/encrypt' ;
3+ import { EncryptRequestBody , PostV1Encrypt } from '../../../src/typedRoutes/api/v1/encrypt' ;
4+ import { PostV2Encrypt } from '../../../src/typedRoutes/api/v2/encrypt' ;
45import { assertDecode } from './common' ;
56import 'should' ;
67import 'should-http' ;
@@ -92,7 +93,7 @@ describe('Encrypt codec tests', function () {
9293 } ) ;
9394
9495 describe ( 'EncryptResponse' , function ( ) {
95- const EncryptResponse = PostEncrypt . response [ 200 ] ;
96+ const EncryptResponse = PostV1Encrypt . response [ 200 ] ;
9697
9798 it ( 'should validate response with required field' , function ( ) {
9899 const validResponse = {
@@ -139,24 +140,41 @@ describe('Encrypt codec tests', function () {
139140 } ) ;
140141 } ) ;
141142
142- describe ( 'PostEncrypt route definition' , function ( ) {
143+ describe ( 'PostV1Encrypt route definition' , function ( ) {
143144 it ( 'should have the correct path' , function ( ) {
144- assert . strictEqual ( PostEncrypt . path , '/api/v[12] /encrypt' ) ;
145+ assert . strictEqual ( PostV1Encrypt . path , '/api/v1 /encrypt' ) ;
145146 } ) ;
146147
147148 it ( 'should have the correct HTTP method' , function ( ) {
148- assert . strictEqual ( PostEncrypt . method , 'POST' ) ;
149+ assert . strictEqual ( PostV1Encrypt . method , 'POST' ) ;
149150 } ) ;
150151
151152 it ( 'should have the correct request configuration' , function ( ) {
152- // Verify the route is configured with a request property
153- assert . ok ( PostEncrypt . request ) ;
153+ assert . ok ( PostV1Encrypt . request ) ;
154154 } ) ;
155155
156156 it ( 'should have the correct response types' , function ( ) {
157- // Check that the response object has the expected status codes
158- assert . ok ( PostEncrypt . response [ 200 ] ) ;
159- assert . ok ( PostEncrypt . response [ 404 ] ) ;
157+ assert . ok ( PostV1Encrypt . response [ 200 ] ) ;
158+ assert . ok ( PostV1Encrypt . response [ 404 ] ) ;
159+ } ) ;
160+ } ) ;
161+
162+ describe ( 'PostV2Encrypt route definition' , function ( ) {
163+ it ( 'should have the correct path' , function ( ) {
164+ assert . strictEqual ( PostV2Encrypt . path , '/api/v2/encrypt' ) ;
165+ } ) ;
166+
167+ it ( 'should have the correct HTTP method' , function ( ) {
168+ assert . strictEqual ( PostV2Encrypt . method , 'POST' ) ;
169+ } ) ;
170+
171+ it ( 'should have the correct request configuration' , function ( ) {
172+ assert . ok ( PostV2Encrypt . request ) ;
173+ } ) ;
174+
175+ it ( 'should have the correct response types' , function ( ) {
176+ assert . ok ( PostV2Encrypt . response [ 200 ] ) ;
177+ assert . ok ( PostV2Encrypt . response [ 404 ] ) ;
160178 } ) ;
161179 } ) ;
162180
@@ -191,7 +209,7 @@ describe('Encrypt codec tests', function () {
191209 result . body . should . have . property ( 'encrypted' ) ;
192210 assert . strictEqual ( result . body . encrypted , mockEncryptResponse ) ;
193211
194- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
212+ const decodedResponse = assertDecode ( PostV1Encrypt . response [ 200 ] , result . body ) ;
195213 assert . strictEqual ( decodedResponse . encrypted , mockEncryptResponse ) ;
196214 } ) ;
197215
@@ -213,7 +231,7 @@ describe('Encrypt codec tests', function () {
213231 result . body . should . have . property ( 'encrypted' ) ;
214232 assert . strictEqual ( result . body . encrypted , mockEncryptResponse ) ;
215233
216- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
234+ const decodedResponse = assertDecode ( PostV2Encrypt . response [ 200 ] , result . body ) ;
217235 assert . strictEqual ( decodedResponse . encrypted , mockEncryptResponse ) ;
218236 } ) ;
219237
@@ -235,7 +253,7 @@ describe('Encrypt codec tests', function () {
235253 assert . strictEqual ( result . status , 200 ) ;
236254 assert . strictEqual ( result . body . encrypted , mockEncryptResponse ) ;
237255
238- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
256+ const decodedResponse = assertDecode ( PostV1Encrypt . response [ 200 ] , result . body ) ;
239257 assert . strictEqual ( decodedResponse . encrypted , mockEncryptResponse ) ;
240258 } ) ;
241259
@@ -257,7 +275,7 @@ describe('Encrypt codec tests', function () {
257275 assert . strictEqual ( result . status , 200 ) ;
258276 assert . strictEqual ( result . body . encrypted , mockEncryptResponse ) ;
259277
260- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
278+ const decodedResponse = assertDecode ( PostV2Encrypt . response [ 200 ] , result . body ) ;
261279 assert . strictEqual ( decodedResponse . encrypted , mockEncryptResponse ) ;
262280 } ) ;
263281
@@ -279,7 +297,7 @@ describe('Encrypt codec tests', function () {
279297 assert . strictEqual ( result . status , 200 ) ;
280298 assert . strictEqual ( result . body . encrypted , mockLongEncrypted ) ;
281299
282- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
300+ const decodedResponse = assertDecode ( PostV1Encrypt . response [ 200 ] , result . body ) ;
283301 assert . strictEqual ( decodedResponse . encrypted , mockLongEncrypted ) ;
284302 } ) ;
285303
@@ -300,7 +318,7 @@ describe('Encrypt codec tests', function () {
300318 assert . strictEqual ( result . status , 200 ) ;
301319 assert . strictEqual ( result . body . encrypted , mockEncryptResponse ) ;
302320
303- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
321+ const decodedResponse = assertDecode ( PostV2Encrypt . response [ 200 ] , result . body ) ;
304322 assert . ok ( decodedResponse ) ;
305323 } ) ;
306324
@@ -321,7 +339,7 @@ describe('Encrypt codec tests', function () {
321339 assert . strictEqual ( result . status , 200 ) ;
322340 assert . strictEqual ( result . body . encrypted , mockEncryptResponse ) ;
323341
324- const decodedResponse = assertDecode ( PostEncrypt . response [ 200 ] , result . body ) ;
342+ const decodedResponse = assertDecode ( PostV1Encrypt . response [ 200 ] , result . body ) ;
325343 assert . ok ( decodedResponse ) ;
326344 } ) ;
327345 } ) ;
0 commit comments