2024-01-29 07:34:10 -08:00
|
|
|
import userEvent from '@testing-library/user-event';
|
|
|
|
import { createComponentRenderer } from '@/__tests__/render';
|
|
|
|
import ExpressionEditorModalInput from '@/components/ExpressionEditorModal/ExpressionEditorModalInput.vue';
|
2024-03-15 10:40:37 -07:00
|
|
|
import { type TestingPinia, createTestingPinia } from '@pinia/testing';
|
|
|
|
import { setActivePinia } from 'pinia';
|
|
|
|
import { waitFor } from '@testing-library/vue';
|
2024-01-29 07:34:10 -08:00
|
|
|
|
2024-03-15 10:40:37 -07:00
|
|
|
describe('ExpressionParameterInput', () => {
|
|
|
|
const renderComponent = createComponentRenderer(ExpressionEditorModalInput);
|
|
|
|
let pinia: TestingPinia;
|
2024-01-29 07:34:10 -08:00
|
|
|
|
2024-03-15 10:40:37 -07:00
|
|
|
beforeEach(() => {
|
|
|
|
pinia = createTestingPinia();
|
|
|
|
setActivePinia(pinia);
|
|
|
|
});
|
2024-01-29 07:34:10 -08:00
|
|
|
|
|
|
|
test.each([
|
|
|
|
['not be editable', 'readonly', true, ''],
|
|
|
|
['be editable', 'not readonly', false, 'test'],
|
|
|
|
])('should %s when %s', async (_, __, isReadOnly, expected) => {
|
|
|
|
const { getByRole } = renderComponent({
|
|
|
|
props: {
|
|
|
|
modelValue: '',
|
|
|
|
path: '',
|
|
|
|
isReadOnly,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-03-15 10:40:37 -07:00
|
|
|
const textbox = await waitFor(() => getByRole('textbox'));
|
|
|
|
await userEvent.type(textbox, 'test');
|
2024-01-29 07:34:10 -08:00
|
|
|
expect(getByRole('textbox')).toHaveTextContent(expected);
|
|
|
|
});
|
|
|
|
});
|