Skip to content

Commit

Permalink
chore: component test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandra shekar Varkala committed Jan 10, 2024
1 parent 38bcfc4 commit 51bfe9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/integrations/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const testRoute = async (route, tcData: TestCaseData) => {
const outputResp = tcData.output.response || ({} as any);

if (tcData.feature === tags.FEATURES.BATCH || tcData.feature === tags.FEATURES.ROUTER) {
//TODO not all test cases have userIds in their metadata.
assertRouterOutput(response.body.output, tcData.input.request.body.input);
}

Expand Down
14 changes: 12 additions & 2 deletions test/testHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const setResponsesForMockAxiosAdapter = ({url, method, data, options}, {response
}

const assertRouterOutput = (output, input) => {
if (!input.metadata) {
return;
if (!Array.isArray(output) || !Array.isArray(input)) {
return
}

const returnedJobids = {};
Expand Down Expand Up @@ -68,6 +68,8 @@ const assertRouterOutput = (output, input) => {
}
});

console.log(userIdJobIdMap);

//The jobids for a user should be in order. If not, there is an issue.
Object.keys(userIdJobIdMap).forEach((userId) => {
const jobIds = userIdJobIdMap[userId];
Expand All @@ -77,6 +79,14 @@ const assertRouterOutput = (output, input) => {
});
};

/*a = {b:3}
console.log(a.b)
input = [{message: {a: "b"}, destination: {a: "b"}, metadata: {jobId: 1}},
{message: {a: "b"}, destination: {a: "b"}, metadata: {jobId: 2}}]
output = [{batchedRequest: {}, metadata: [{jobId: 2}], destination: {a: "b"}, statusCode: 200},
{batchedRequest: {}, metadata: [{jobId: 1}], destination: {a: "b"}, statusCode: 200}]
assertRouterOutput(output, input)*/

module.exports = {
getFuncTestData,
responses,
Expand Down

0 comments on commit 51bfe9d

Please sign in to comment.