Skip to content

Commit

Permalink
Added console error check to every test
Browse files Browse the repository at this point in the history
  • Loading branch information
doracretu3pillar committed Sep 21, 2024
1 parent c478147 commit 40fbcbb
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ describe('Nodes Agents:: ', () => {
});

it('should pick the pmm-server from the list of agents when pmm-server node is chosen', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

InventoryService.getNodes = () =>
Promise.resolve({
nodes: nodesMock,
Expand All @@ -75,9 +77,14 @@ describe('Nodes Agents:: ', () => {
const formValues = formAPI.getState().values;
expect(formValues.pmm_agent_id.value).toBe('pmm-server');
expect(formValues.node.value).toBe('pmm-server');
expect(consoleErrorSpy).toHaveBeenCalled();

consoleErrorSpy.mockRestore();
});

it('should change the address to localhost when the agent id is not pmmServer', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

InventoryService.getNodes = () =>
Promise.resolve({
nodes: nodesMockMultipleAgentsNoPMMServer,
Expand All @@ -97,9 +104,14 @@ describe('Nodes Agents:: ', () => {

const formValues = formAPI.getState().values;
expect(formValues.address).toBe('localhost');
expect(consoleErrorSpy).toHaveBeenCalled();

consoleErrorSpy.mockRestore();
});

it('should have the node/agent selected values when submit', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

InventoryService.getNodes = () =>
Promise.resolve({
nodes: nodesMock,
Expand Down Expand Up @@ -128,5 +140,8 @@ describe('Nodes Agents:: ', () => {
expect.anything(),
expect.anything()
);
expect(consoleErrorSpy).toHaveBeenCalled();

consoleErrorSpy.mockRestore();
});
});

0 comments on commit 40fbcbb

Please sign in to comment.