11import * as assert from 'assert' ;
22import * as t from 'io-ts' ;
3- import { LoginRequest , PostLogin } from '../../../src/typedRoutes/api/common/login' ;
3+ import { LoginRequest , PostV1Login } from '../../../src/typedRoutes/api/v1/login' ;
4+ import { PostV2Login } from '../../../src/typedRoutes/api/v2/login' ;
45import { assertDecode } from './common' ;
56import 'should' ;
67import 'should-http' ;
@@ -130,7 +131,7 @@ describe('Login codec tests', function () {
130131 } ) ;
131132
132133 describe ( 'LoginResponse' , function ( ) {
133- const LoginResponse = PostLogin . response [ 200 ] ;
134+ const LoginResponse = PostV1Login . response [ 200 ] ;
134135
135136 it ( 'should validate response with all required fields' , function ( ) {
136137 const validResponse = {
@@ -245,24 +246,41 @@ describe('Login codec tests', function () {
245246 } ) ;
246247 } ) ;
247248
248- describe ( 'PostLogin route definition' , function ( ) {
249+ describe ( 'PostV1Login route definition' , function ( ) {
249250 it ( 'should have the correct path' , function ( ) {
250- assert . strictEqual ( PostLogin . path , '/api/v[12] /user/login' ) ;
251+ assert . strictEqual ( PostV1Login . path , '/api/v1 /user/login' ) ;
251252 } ) ;
252253
253254 it ( 'should have the correct HTTP method' , function ( ) {
254- assert . strictEqual ( PostLogin . method , 'POST' ) ;
255+ assert . strictEqual ( PostV1Login . method , 'POST' ) ;
255256 } ) ;
256257
257258 it ( 'should have the correct request configuration' , function ( ) {
258- // Verify the route is configured with a request property
259- assert . ok ( PostLogin . request ) ;
259+ assert . ok ( PostV1Login . request ) ;
260260 } ) ;
261261
262262 it ( 'should have the correct response types' , function ( ) {
263- // Check that the response object has the expected status codes
264- assert . ok ( PostLogin . response [ 200 ] ) ;
265- assert . ok ( PostLogin . response [ 404 ] ) ;
263+ assert . ok ( PostV1Login . response [ 200 ] ) ;
264+ assert . ok ( PostV1Login . response [ 404 ] ) ;
265+ } ) ;
266+ } ) ;
267+
268+ describe ( 'PostV2Login route definition' , function ( ) {
269+ it ( 'should have the correct path' , function ( ) {
270+ assert . strictEqual ( PostV2Login . path , '/api/v2/user/login' ) ;
271+ } ) ;
272+
273+ it ( 'should have the correct HTTP method' , function ( ) {
274+ assert . strictEqual ( PostV2Login . method , 'POST' ) ;
275+ } ) ;
276+
277+ it ( 'should have the correct request configuration' , function ( ) {
278+ assert . ok ( PostV2Login . request ) ;
279+ } ) ;
280+
281+ it ( 'should have the correct response types' , function ( ) {
282+ assert . ok ( PostV2Login . response [ 200 ] ) ;
283+ assert . ok ( PostV2Login . response [ 404 ] ) ;
266284 } ) ;
267285 } ) ;
268286
@@ -304,7 +322,7 @@ describe('Login codec tests', function () {
304322 assert . strictEqual ( result . body . email , mockLoginResponse . email ) ;
305323 assert . strictEqual ( result . body . forceSMS , mockLoginResponse . forceSMS ) ;
306324
307- const decodedResponse = assertDecode ( PostLogin . response [ 200 ] , result . body ) ;
325+ const decodedResponse = assertDecode ( PostV1Login . response [ 200 ] , result . body ) ;
308326 assert . strictEqual ( decodedResponse . email , mockLoginResponse . email ) ;
309327 } ) ;
310328
@@ -329,7 +347,7 @@ describe('Login codec tests', function () {
329347 assert . strictEqual ( result . body . email , mockLoginResponse . email ) ;
330348 assert . strictEqual ( result . body . forceSMS , mockLoginResponse . forceSMS ) ;
331349
332- const decodedResponse = assertDecode ( PostLogin . response [ 200 ] , result . body ) ;
350+ const decodedResponse = assertDecode ( PostV2Login . response [ 200 ] , result . body ) ;
333351 assert . strictEqual ( decodedResponse . email , mockLoginResponse . email ) ;
334352 } ) ;
335353
@@ -375,7 +393,7 @@ describe('Login codec tests', function () {
375393 result . body . should . have . property ( 'forceSMS' ) ;
376394 result . body . should . have . property ( 'extensible' ) ;
377395
378- const decodedResponse = assertDecode ( PostLogin . response [ 200 ] , result . body ) ;
396+ const decodedResponse = assertDecode ( PostV1Login . response [ 200 ] , result . body ) ;
379397 assert . strictEqual ( decodedResponse . email , mockFullResponse . email ) ;
380398 assert . strictEqual ( decodedResponse . extensible , mockFullResponse . extensible ) ;
381399 assert . strictEqual ( decodedResponse . initialHash , mockFullResponse . initialHash ) ;
@@ -423,7 +441,7 @@ describe('Login codec tests', function () {
423441 result . body . should . have . property ( 'forceSMS' ) ;
424442 result . body . should . have . property ( 'extensible' ) ;
425443
426- const decodedResponse = assertDecode ( PostLogin . response [ 200 ] , result . body ) ;
444+ const decodedResponse = assertDecode ( PostV2Login . response [ 200 ] , result . body ) ;
427445 assert . strictEqual ( decodedResponse . email , mockFullResponse . email ) ;
428446 assert . strictEqual ( decodedResponse . extensible , mockFullResponse . extensible ) ;
429447 assert . strictEqual ( decodedResponse . initialHash , mockFullResponse . initialHash ) ;
@@ -447,7 +465,7 @@ describe('Login codec tests', function () {
447465 result . body . should . have . property ( 'email' ) ;
448466 result . body . should . have . property ( 'forceSMS' ) ;
449467
450- const decodedResponse = assertDecode ( PostLogin . response [ 200 ] , result . body ) ;
468+ const decodedResponse = assertDecode ( PostV2Login . response [ 200 ] , result . body ) ;
451469 assert . ok ( decodedResponse ) ;
452470 } ) ;
453471 } ) ;
0 commit comments