Skip to content

Commit 0918063

Browse files
committed
jest update for TrendlineOption provided parameters display select input
1 parent 28cc4ea commit 0918063

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

packages/components/src/internal/components/chart/TrendlineOption.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ describe('TrendlineOption', () => {
7272
expect(document.querySelectorAll('.field-option-icon')).toHaveLength(0);
7373
expect(document.querySelectorAll('input[name="trendlineAsymptoteMin"]')).toHaveLength(0);
7474
expect(document.querySelectorAll('input[name="trendlineAsymptoteMax"]')).toHaveLength(0);
75+
expect(document.querySelectorAll('input[name="trendlineParameters"]')).toHaveLength(0);
7576
});
7677

7778
test('shown with x-axis value selected, non-date', async () => {
7879
const fieldValues = {
7980
x: { data: { jsonType: 'int' }, value: 'field1' },
8081
trendlineAsymptoteMin: { value: undefined },
8182
trendlineAsymptoteMax: { value: undefined },
83+
trendlineParameters: { value: undefined },
8284
};
8385
render(
8486
<TrendlineOption
@@ -111,6 +113,7 @@ describe('TrendlineOption', () => {
111113
x: { data: { jsonType: 'date' }, value: 'field1' },
112114
trendlineAsymptoteMin: { value: undefined },
113115
trendlineAsymptoteMax: { value: undefined },
116+
trendlineParameters: { value: undefined },
114117
};
115118
render(
116119
<TrendlineOption
@@ -134,6 +137,7 @@ describe('TrendlineOption', () => {
134137
x: { data: { type: 'time' }, value: 'field1' },
135138
trendlineAsymptoteMin: { value: undefined },
136139
trendlineAsymptoteMax: { value: undefined },
140+
trendlineParameters: { value: undefined },
137141
};
138142
render(
139143
<TrendlineOption
@@ -158,6 +162,7 @@ describe('TrendlineOption', () => {
158162
trendlineType: { value: 'option1', showMin: true, showMax: true },
159163
trendlineAsymptoteMin: { value: '0.1' },
160164
trendlineAsymptoteMax: { value: '1.0' },
165+
trendlineParameters: { value: undefined },
161166
};
162167
render(
163168
<TrendlineOption
@@ -198,6 +203,7 @@ describe('TrendlineOption', () => {
198203
trendlineType: { value: 'option1', showMin: true, showMax: false },
199204
trendlineAsymptoteMin: { value: '0.1' },
200205
trendlineAsymptoteMax: { value: undefined },
206+
trendlineParameters: { value: undefined },
201207
};
202208
render(
203209
<TrendlineOption
@@ -231,4 +237,34 @@ describe('TrendlineOption', () => {
231237
expect(document.querySelectorAll('input[name="trendlineAsymptoteMax"]')).toHaveLength(0);
232238
expect(document.querySelector('input[name="trendlineAsymptoteMin"]').getAttribute('value')).toBe('');
233239
});
240+
241+
test('show provided parameters in trendline gear tooltip', async () => {
242+
const fieldValues = {
243+
x: { data: { jsonType: 'int' }, value: 'field1' },
244+
trendlineType: { value: 'option1', showMin: true, showMax: true },
245+
trendlineAsymptoteMin: { value: undefined },
246+
trendlineAsymptoteMax: { value: undefined },
247+
trendlineParameters: { value: 'field1' },
248+
};
249+
render(
250+
<TrendlineOption
251+
fieldValues={fieldValues}
252+
model={model}
253+
onFieldChange={jest.fn()}
254+
schemaQuery={new SchemaQuery('assay', 'query')}
255+
selectedType={LINE_PLOT_TYPE}
256+
/>
257+
);
258+
await waitFor(() => {
259+
expect(document.querySelectorAll('.trendline-option')).toHaveLength(1);
260+
});
261+
262+
expect(document.querySelectorAll('.select-input')).toHaveLength(1); // trendline type
263+
expect(document.querySelectorAll('.field-option-icon')).toHaveLength(1);
264+
265+
await userEvent.click(document.querySelector('.fa-gear'));
266+
expect(document.querySelectorAll('.select-input')).toHaveLength(2); // trendline type and now provided parameters
267+
expect(document.querySelectorAll('input[name="trendlineParameters"]')).toHaveLength(1);
268+
expect(document.querySelector('input[name="trendlineParameters"]').getAttribute('value')).toBe('field1');
269+
});
234270
});

0 commit comments

Comments
 (0)