44 AcceptShareRequestParams ,
55 AcceptShareRequestBody ,
66 PostAcceptShare ,
7- } from '../../../src/typedRoutes/api/common /acceptShare' ;
7+ } from '../../../src/typedRoutes/api/v1 /acceptShare' ;
88
99/**
1010 * Helper function to test io-ts codec decoding
@@ -54,53 +54,26 @@ describe('AcceptShare codec tests', function () {
5454 userPassword : 'mySecurePassword' ,
5555 newWalletPassphrase : 'myNewPassphrase' ,
5656 overrideEncryptedXprv : 'encryptedXprvString' ,
57- walletShareId : 'walletShare123' ,
5857 } ;
5958
6059 const decoded = assertDecode ( t . type ( AcceptShareRequestBody ) , validBody ) ;
6160 assert . strictEqual ( decoded . userPassword , validBody . userPassword ) ;
6261 assert . strictEqual ( decoded . newWalletPassphrase , validBody . newWalletPassphrase ) ;
6362 assert . strictEqual ( decoded . overrideEncryptedXprv , validBody . overrideEncryptedXprv ) ;
64- assert . strictEqual ( decoded . walletShareId , validBody . walletShareId ) ;
6563 } ) ;
6664
67- it ( 'should validate body with only required fields' , function ( ) {
68- const validBody = {
69- walletShareId : 'walletShare123' ,
70- } ;
65+ it ( 'should validate empty body since all fields are optional' , function ( ) {
66+ const validBody = { } ;
7167
7268 const decoded = assertDecode ( t . type ( AcceptShareRequestBody ) , validBody ) ;
73- assert . strictEqual ( decoded . walletShareId , validBody . walletShareId ) ;
7469 assert . strictEqual ( decoded . userPassword , undefined ) ;
7570 assert . strictEqual ( decoded . newWalletPassphrase , undefined ) ;
7671 assert . strictEqual ( decoded . overrideEncryptedXprv , undefined ) ;
7772 } ) ;
7873
79- it ( 'should reject body with missing walletShareId' , function ( ) {
80- const invalidBody = {
81- userPassword : 'mySecurePassword' ,
82- newWalletPassphrase : 'myNewPassphrase' ,
83- } ;
84-
85- assert . throws ( ( ) => {
86- assertDecode ( t . type ( AcceptShareRequestBody ) , invalidBody ) ;
87- } ) ;
88- } ) ;
89-
90- it ( 'should reject body with non-string walletShareId' , function ( ) {
91- const invalidBody = {
92- walletShareId : 12345 , // number instead of string
93- } ;
94-
95- assert . throws ( ( ) => {
96- assertDecode ( t . type ( AcceptShareRequestBody ) , invalidBody ) ;
97- } ) ;
98- } ) ;
99-
10074 it ( 'should reject body with non-string optional fields' , function ( ) {
10175 const invalidBody = {
10276 userPassword : 12345 , // number instead of string
103- walletShareId : 'walletShare123' ,
10477 } ;
10578
10679 assert . throws ( ( ) => {
@@ -110,16 +83,6 @@ describe('AcceptShare codec tests', function () {
11083 } ) ;
11184
11285 describe ( 'Edge cases' , function ( ) {
113- it ( 'should handle empty strings for required fields' , function ( ) {
114- const body = {
115- walletShareId : '' , // empty string
116- } ;
117-
118- // Empty strings are still valid strings
119- const decoded = assertDecode ( t . type ( AcceptShareRequestBody ) , body ) ;
120- assert . strictEqual ( decoded . walletShareId , '' ) ;
121- } ) ;
122-
12386 describe ( 'PostAcceptShare route definition' , function ( ) {
12487 it ( 'should have the correct path' , function ( ) {
12588 assert . strictEqual ( PostAcceptShare . path , '/api/v1/walletshare/:shareId/acceptShare' ) ;
@@ -146,7 +109,6 @@ describe('AcceptShare codec tests', function () {
146109 userPassword : '' ,
147110 newWalletPassphrase : '' ,
148111 overrideEncryptedXprv : '' ,
149- walletShareId : 'walletShare123' ,
150112 } ;
151113
152114 const decoded = assertDecode ( t . type ( AcceptShareRequestBody ) , body ) ;
@@ -157,13 +119,13 @@ describe('AcceptShare codec tests', function () {
157119
158120 it ( 'should handle additional unknown properties' , function ( ) {
159121 const body = {
160- walletShareId : 'walletShare123 ' ,
122+ userPassword : 'password123 ' ,
161123 unknownProperty : 'some value' ,
162124 } ;
163125
164126 // io-ts with t.exact() strips out additional properties
165127 const decoded = assertDecode ( t . exact ( t . type ( AcceptShareRequestBody ) ) , body ) ;
166- assert . strictEqual ( decoded . walletShareId , 'walletShare123 ' ) ;
128+ assert . strictEqual ( decoded . userPassword , 'password123 ' ) ;
167129 // @ts -expect-error - unknownProperty doesn't exist on the type
168130 assert . strictEqual ( decoded . unknownProperty , undefined ) ;
169131 } ) ;
0 commit comments