Skip to content

Commit

Permalink
SK-968-send-detokenize-value-data-type-in-detokenize-reveal-interface…
Browse files Browse the repository at this point in the history
…-response (#333)
  • Loading branch information
skyflow-bharti authored Oct 4, 2023
1 parent 5d134e8 commit 4587baa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/core-utils/reveal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ interface IApiSuccessResponse {

const formatForPureJsSuccess = (response: IApiSuccessResponse) => {
const currentResponseRecords = response.records;
return currentResponseRecords.map((record) => ({ token: record.token, value: record.value }));
return currentResponseRecords.map((record) => (
{ token: record.token, value: record.value, valueType: record.valueType }));
};

const formatForPureJsFailure = (cause, tokenId:string) => ({
Expand Down Expand Up @@ -171,6 +172,7 @@ export const formatRecordsForClient = (response: IRevealResponseType) => {
if (response.records) {
const successRecords = response.records.map((record) => ({
token: record.token,
valueType: record.valueType,
}));
if (response.errors) return { success: successRecords, errors: response.errors };
return { success: successRecords };
Expand Down
6 changes: 3 additions & 3 deletions tests/core-utils/reveal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ describe('Reveal PureJs- get() Method Input', () => {

describe("formatRecordsForClient fn test",()=>{
test("only success records",()=>{
const testInput = {"records":[{"token":"7402-2242-2342-232","value":"231"}] }
const testInput = {"records":[{"token":"7402-2242-2342-232","value":"231", "valueType" : "STRING"}] }
const fnResponse = formatRecordsForClient(testInput, {"7402-2242-2342-232": "231"});
expect(fnResponse.success.length).toBe(1);
expect(fnResponse.errors).toBeUndefined();
});
test("both success and error records",()=>{
const testInput = {"records":[{"token":"7402-2242-2342-232","value":"231"}],"errors":[{"token":"3232-6434-3253-4221"}]};
const testInput = {"records":[{"token":"7402-2242-2342-232","value":"231", "valueType" : "STRING"}],"errors":[{"token":"3232-6434-3253-4221"}]};
const fnResponse = formatRecordsForClient(testInput,{"7402-2242-2342-232": "231"});
expect(fnResponse.errors.length).toBe(1);
expect(fnResponse.success.length).toBe(1);
Expand All @@ -111,7 +111,7 @@ describe("formatRecordsForIframe fn test",()=>{
expect(fnResponse).toStrictEqual({});
});
test("with records should return token value object",()=>{
const testInput = {"records":[{token:"7823-323-242-2232",value:"token_value"}]};
const testInput = {"records":[{token:"7823-323-242-2232",value:"token_value","valueType" : "STRING"}]};
const fnResponse = formatRecordsForIframe(testInput);
expect(fnResponse).toStrictEqual({"7823-323-242-2232":"token_value"});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/core/internal/reveal/reveal-frame-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('RevealFrameController Class', () => {
fetchRecordsByTokenId.mockImplementation(()=>{
return new Promise((resolve,)=>{
resolve({
records:[{token:"1815-6223-1073-1425",value:"3242"}]
records:[{token:"1815-6223-1073-1425",value:"3242", valueType : "STRING"}]
})
});
})
Expand Down

0 comments on commit 4587baa

Please sign in to comment.