Skip to content

Commit

Permalink
update tests to use toBeInTheDocument
Browse files Browse the repository at this point in the history
review changes @gergoabraham
  • Loading branch information
ashokaditya committed Apr 5, 2023
1 parent 7b58b24 commit 177a31b
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ describe('When using the `ExecuteActionHostResponse` component', () => {

it('should show shell info and shell code', async () => {
render();
expect(renderResult.getByTestId(`test-executeResponseOutput-context`)).toBeTruthy();
expect(renderResult.getByTestId(`test-executeResponseOutput-shell`)).toBeTruthy();
expect(renderResult.getByTestId(`test-executeResponseOutput-cwd`)).toBeTruthy();
const { queryByTestId } = renderResult;
expect(queryByTestId(`test-executeResponseOutput-context`)).toBeInTheDocument();
expect(queryByTestId(`test-executeResponseOutput-shell`)).toBeInTheDocument();
expect(queryByTestId(`test-executeResponseOutput-cwd`)).toBeInTheDocument();
});

it('should show execute context accordion as `closed`', async () => {
Expand All @@ -61,14 +62,16 @@ describe('When using the `ExecuteActionHostResponse` component', () => {

it('should show current working directory', async () => {
render();
expect(renderResult.getByTestId(`test-executeResponseOutput-context`)).toBeTruthy();
expect(renderResult.getByTestId(`test-executeResponseOutput-cwd`)).toBeTruthy();
const { queryByTestId } = renderResult;
expect(queryByTestId(`test-executeResponseOutput-context`)).toBeInTheDocument();
expect(queryByTestId(`test-executeResponseOutput-cwd`)).toBeInTheDocument();
});

it('should show execute output and execute errors', async () => {
render();
expect(renderResult.getByTestId(`test-executeResponseOutput-${outputSuffix}`)).toBeTruthy();
expect(renderResult.getByTestId(`test-executeResponseOutput-error`)).toBeTruthy();
const { queryByTestId } = renderResult;
expect(queryByTestId(`test-executeResponseOutput-${outputSuffix}`)).toBeInTheDocument();
expect(queryByTestId(`test-executeResponseOutput-error`)).toBeInTheDocument();
});

it('should show execute output accordion as `open`', async () => {
Expand All @@ -88,8 +91,8 @@ describe('When using the `ExecuteActionHostResponse` component', () => {
},
},
};
render();

render();
expect(
renderResult.getByTestId(`test-executeResponseOutput-${outputSuffix}`).textContent
).toContain(`Execution output (truncated)${getEmptyValue()}`);
Expand All @@ -105,17 +108,19 @@ describe('When using the `ExecuteActionHostResponse` component', () => {
},
},
};
render();

render();
expect(renderResult.getByTestId('test-executeResponseOutput-error').textContent).toContain(
`Execution error (truncated)${getEmptyValue()}`
);
});

it('should not show execute output accordions when no output in action details', () => {
(renderProps.action as ActionDetails).outputs = undefined;

render();
expect(renderResult.queryByTestId(`test-executeResponseOutput-context`)).toBeNull();
expect(renderResult.queryByTestId(`test-executeResponseOutput-${outputSuffix}`)).toBeNull();
const { queryByTestId } = renderResult;
expect(queryByTestId(`test-executeResponseOutput-context`)).not.toBeInTheDocument();
expect(queryByTestId(`test-executeResponseOutput-${outputSuffix}`)).not.toBeInTheDocument();
});
});

0 comments on commit 177a31b

Please sign in to comment.