Skip to content

Commit 517d00c

Browse files
committed
create test cases for advanced parameters options
1 parent eda7c87 commit 517d00c

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* eslint-disable no-unused-vars */
2+
/* eslint-disable no-undef */
3+
import { render, screen, fireEvent } from '@testing-library/react';
4+
import { Form } from '../form';
5+
import { AMINO_ACID_SEQUENCE } from './mock_data/sequences';
6+
import data from './mock_data/databases.json';
7+
import userEvent from '@testing-library/user-event';
8+
import '@testing-library/jest-dom/extend-expect';
9+
import '@testing-library/react/dont-cleanup-after-each';
10+
11+
export const setMockJSONResult = (result) => {
12+
global.$.getJSON = (_, cb) => cb(result);
13+
};
14+
describe('ADVANCED PARAMETERS', () => {
15+
const getInputElement = () => screen.getByRole('textbox', { name: '' });
16+
test('should not render the link to advanced parameters modal if blast algorithm is unknown', () => {
17+
setMockJSONResult(data);
18+
const {container } =render(<Form onSequenceTypeChanged={() => { }
19+
} />);
20+
const modalButton = container.querySelector('[data-target="#help"]');
21+
expect(modalButton).toBeNull();
22+
});
23+
test('should render the link to advanced parameters modal if blast algorithm is known', () => {
24+
setMockJSONResult(data);
25+
const {container } =render(<Form onSequenceTypeChanged={() => { }
26+
} />);
27+
28+
const inputEl = getInputElement();
29+
// populate search and select dbs to determine blast algorithm
30+
fireEvent.change(inputEl, { target: { value: AMINO_ACID_SEQUENCE } });
31+
const proteinSelectAllBtn = screen.getByRole('heading', { name: /protein databases/i }).parentElement.querySelector('button');
32+
fireEvent.click(proteinSelectAllBtn);
33+
const modalButton = container.querySelector('[data-target="#help"]');
34+
expect(modalButton).not.toBeNull();
35+
});
36+
});

0 commit comments

Comments
 (0)