|
| 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