Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Replace snapshot with tests for error text - 7
Browse files Browse the repository at this point in the history
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
  • Loading branch information
gejohnston committed Jun 16, 2023
1 parent 8712c31 commit 5701fdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 88 deletions.
23 changes: 15 additions & 8 deletions packages/cmd/__tests__/CommandProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ describe("Command Processor", () => {
expect(stderrText).toContain("Profile loading failed!");
expect(commandResponse.message).toEqual("Profile loading failed!");
expect(commandResponse.error?.msg).toEqual("Profile loading failed!");
expect(commandResponse.error?.additionalDetails).toEqual(undefined);
expect(commandResponse.error?.additionalDetails).not.toBeDefined();
});

it("should handle not being able to instantiate the handler", async () => {
Expand Down Expand Up @@ -1281,12 +1281,12 @@ describe("Command Processor", () => {
expect(commandResponse.message).toMatch(
/Unexpected Command Error: Cannot read (property 'doesnt' of undefined|properties of undefined \(reading 'doesnt'\))/
);
expect(commandResponse.error.msg).toMatch(/Cannot read (property 'doesnt' of undefined|properties of undefined \(reading 'doesnt'\))/);
expect(commandResponse.stdout.toString().length).toBe(0);
expect(commandResponse.stderr.toString()).toContain("Unexpected Command Error:");
expect(commandResponse.stderr.toString()).toContain("Message:");
expect(commandResponse.stderr.toString()).toContain("Stack:");
expect(commandResponse.error.stack).toMatch(
expect(commandResponse?.error?.msg).toMatch(/Cannot read (property 'doesnt' of undefined|properties of undefined \(reading 'doesnt'\))/);
expect(commandResponse?.stdout?.toString().length).toBe(0);
expect(commandResponse?.stderr?.toString()).toContain("Unexpected Command Error:");
expect(commandResponse?.stderr?.toString()).toContain("Message:");
expect(commandResponse?.stderr?.toString()).toContain("Stack:");
expect(commandResponse?.error?.stack).toMatch(
/TypeError: Cannot read (property 'doesnt' of undefined|properties of undefined \(reading 'doesnt'\))/
);
});
Expand Down Expand Up @@ -1330,7 +1330,14 @@ describe("Command Processor", () => {
};
const commandResponse: ICommandResponse = await processor.invoke(parms);
expect(commandResponse).toBeDefined();
expect(commandResponse).toMatchSnapshot();
const stderrText = (commandResponse.stderr as Buffer).toString();
expect(stderrText).toContain("Command Error:");
expect(stderrText).toContain("Rejected with a message");
expect(commandResponse.success).toEqual(false);
expect(commandResponse.exitCode).toEqual(1);
expect(commandResponse.message).toEqual("Rejected with a message");
expect(commandResponse.error?.msg).toEqual("Rejected with a message");
expect(commandResponse.error?.additionalDetails).not.toBeDefined();
});

it("should handle the handler rejecting with no messages", async () => {
Expand Down
80 changes: 0 additions & 80 deletions packages/cmd/__tests__/__snapshots__/CommandProcessor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -243,86 +243,6 @@ Object {
}
`;

exports[`Command Processor should handle the handler rejecting with a message 1`] = `
Object {
"data": Object {},
"error": Object {
"msg": "Rejected with a message",
},
"exitCode": 1,
"message": "Rejected with a message",
"stderr": Object {
"data": Array [
27,
91,
51,
49,
109,
67,
111,
109,
109,
97,
110,
100,
32,
69,
114,
114,
111,
114,
58,
27,
91,
51,
57,
109,
10,
27,
91,
51,
49,
109,
27,
91,
51,
57,
109,
82,
101,
106,
101,
99,
116,
101,
100,
32,
119,
105,
116,
104,
32,
97,
32,
109,
101,
115,
115,
97,
103,
101,
10,
],
"type": "Buffer",
},
"stdout": Object {
"data": Array [],
"type": "Buffer",
},
"success": false,
}
`;

exports[`Command Processor should handle the handler rejecting with no messages 1`] = `
Object {
"data": Object {},
Expand Down

0 comments on commit 5701fdc

Please sign in to comment.