Skip to content

Commit f146ef7

Browse files
committed
refactor: changed some UTs and JSdocs
TICKET: WP-5443
1 parent 1069b31 commit f146ef7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

modules/express/src/typedRoutes/api/v2/ofcSignPayload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import { BitgoExpressError } from '../../schemas/error';
99
export const OfcSignPayloadBody = {
1010
/** The ID of the OFC wallet to sign the payload with. */
1111
walletId: NonEmptyString,
12-
/** The payload to sign. Will always decode into a JSON object. */
12+
/** The payload to sign. The input can either be a stringified JSON, or a JSON object. */
1313
payload: t.union([Json, t.string.pipe(JsonFromString)]),
1414
/** The passphrase to decrypt the user key. */
1515
walletPassphrase: optional(t.string),
16-
};
16+
} as const;
1717

1818
export const OfcSignPayloadResponse200 = t.type({
1919
/** The string form of the JSON payload that was signed. */

modules/express/test/unit/clientRoutes/signPayload.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ describe('Sign an arbitrary payload with trading account key', function () {
6161
},
6262
query: {},
6363
} as unknown as ExpressApiRouteRequest<'express.ofc.signPayload', 'post'>;
64-
await handleV2OFCSignPayload(req).should.be.resolvedWith(expectedResponse);
64+
const result = await handleV2OFCSignPayload(req).should.be.resolvedWith(expectedResponse);
65+
decodeOrElse('OfcSignPayloadResponse200', OfcSignPayloadResponse[200], result, (_) => {
66+
throw new Error(`Response did not match expected codec`);
67+
});
6568
});
6669
it('should return a signed payload with type as json string', async function () {
6770
const expectedResponse = {
@@ -80,7 +83,10 @@ describe('Sign an arbitrary payload with trading account key', function () {
8083
},
8184
query: {},
8285
} as unknown as ExpressApiRouteRequest<'express.ofc.signPayload', 'post'>;
83-
await handleV2OFCSignPayload(req).should.be.resolvedWith(expectedResponse);
86+
const result = await handleV2OFCSignPayload(req).should.be.resolvedWith(expectedResponse);
87+
decodeOrElse('OfcSignPayloadResponse200', OfcSignPayloadResponse[200], result, (_) => {
88+
throw new Error(`Response did not match expected codec`);
89+
});
8490
});
8591
it('should decode handler response with OfcSignPayloadResponse codec', async function () {
8692
const expected = {

0 commit comments

Comments
 (0)