Skip to content

Commit e77b83f

Browse files
committed
[ML] Add jest tests.
1 parent 19d6b79 commit e77b83f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix_vega_lite_spec.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* 2.0.
66
*/
77

8+
import 'jest-canvas-mock';
9+
810
// @ts-ignore
911
import { compile } from 'vega-lite/build/vega-lite';
1012

@@ -156,4 +158,25 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
156158
{ field: 'y', type: 'quantitative' },
157159
]);
158160
});
161+
162+
it('should escape special characters', () => {
163+
const data = [{ ['x.a']: 1, ['y[a]']: 1 }];
164+
165+
const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(
166+
data,
167+
['x.a', 'y[a]'],
168+
euiThemeLight,
169+
undefined,
170+
'the-color-field',
171+
LEGEND_TYPES.NOMINAL
172+
);
173+
174+
// column values should be escaped
175+
expect(vegaLiteSpec.repeat).toEqual({
176+
column: ['x\\.a', 'y\\[a\\]'],
177+
row: ['y\\[a\\]', 'x\\.a'],
178+
});
179+
// raw data should not be escaped
180+
expect(vegaLiteSpec.spec.data.values).toEqual(data);
181+
});
159182
});

0 commit comments

Comments
 (0)