Skip to content

Commit

Permalink
update jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Nov 9, 2022
1 parent 5dd9d01 commit 209d813
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
it('should return the default spec for non-outliers without a legend', () => {
const data = [{ x: 1, y: 1 }];

const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(data, ['x', 'y'], euiThemeLight);
const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(data, [], ['x', 'y'], euiThemeLight);
const specForegroundLayer = vegaLiteSpec.spec.layer[0];

// A valid Vega Lite spec shouldn't throw an error when compiled.
expect(() => compile(vegaLiteSpec)).not.toThrow();
Expand All @@ -82,17 +83,17 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
column: ['x', 'y'],
row: ['y', 'x'],
});
expect(vegaLiteSpec.spec.data.values).toEqual(data);
expect(vegaLiteSpec.spec.mark).toEqual({
expect(specForegroundLayer.data.values).toEqual(data);
expect(specForegroundLayer.mark).toEqual({
opacity: 0.75,
size: 8,
type: 'circle',
});
expect(vegaLiteSpec.spec.encoding.color).toEqual({
expect(specForegroundLayer.encoding.color).toEqual({
condition: [{ selection: USER_SELECTION }, { selection: SINGLE_POINT_CLICK }],
value: COLOR_BLUR,
});
expect(vegaLiteSpec.spec.encoding.tooltip).toEqual([
expect(specForegroundLayer.encoding.tooltip).toEqual([
{ field: 'x', type: 'quantitative' },
{ field: 'y', type: 'quantitative' },
]);
Expand All @@ -101,7 +102,8 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
it('should return the spec for outliers', () => {
const data = [{ x: 1, y: 1 }];

const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(data, ['x', 'y'], euiThemeLight, 'ml');
const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(data, [], ['x', 'y'], euiThemeLight, 'ml');
const specForegroundLayer = vegaLiteSpec.spec.layer[0];

// A valid Vega Lite spec shouldn't throw an error when compiled.
expect(() => compile(vegaLiteSpec)).not.toThrow();
Expand All @@ -110,13 +112,13 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
column: ['x', 'y'],
row: ['y', 'x'],
});
expect(vegaLiteSpec.spec.data.values).toEqual(data);
expect(vegaLiteSpec.spec.mark).toEqual({
expect(specForegroundLayer.data.values).toEqual(data);
expect(specForegroundLayer.mark).toEqual({
opacity: 0.75,
size: 8,
type: 'circle',
});
expect(vegaLiteSpec.spec.encoding.color).toEqual({
expect(specForegroundLayer.encoding.color).toEqual({
condition: {
selection: USER_SELECTION,
field: 'is_outlier',
Expand All @@ -127,7 +129,7 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
},
value: COLOR_BLUR,
});
expect(vegaLiteSpec.spec.encoding.tooltip).toEqual([
expect(specForegroundLayer.encoding.tooltip).toEqual([
{ field: 'x', type: 'quantitative' },
{ field: 'y', type: 'quantitative' },
{
Expand All @@ -144,12 +146,14 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {

const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(
data,
[],
['x', 'y'],
euiThemeLight,
undefined,
'the-color-field',
LEGEND_TYPES.NOMINAL
);
const specForegroundLayer = vegaLiteSpec.spec.layer[0];

// A valid Vega Lite spec shouldn't throw an error when compiled.
expect(() => compile(vegaLiteSpec)).not.toThrow();
Expand All @@ -158,13 +162,13 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
column: ['x', 'y'],
row: ['y', 'x'],
});
expect(vegaLiteSpec.spec.data.values).toEqual(data);
expect(vegaLiteSpec.spec.mark).toEqual({
expect(specForegroundLayer.data.values).toEqual(data);
expect(specForegroundLayer.mark).toEqual({
opacity: 0.75,
size: 8,
type: 'circle',
});
expect(vegaLiteSpec.spec.encoding.color).toEqual({
expect(specForegroundLayer.encoding.color).toEqual({
condition: {
selection: USER_SELECTION,
field: 'the-color-field',
Expand All @@ -175,7 +179,7 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {
},
value: COLOR_BLUR,
});
expect(vegaLiteSpec.spec.encoding.tooltip).toEqual([
expect(specForegroundLayer.encoding.tooltip).toEqual([
{ field: 'the-color-field', type: 'nominal' },
{ field: 'x', type: 'quantitative' },
{ field: 'y', type: 'quantitative' },
Expand All @@ -187,19 +191,21 @@ describe('getScatterplotMatrixVegaLiteSpec()', () => {

const vegaLiteSpec = getScatterplotMatrixVegaLiteSpec(
data,
[],
['x.a', 'y[a]'],
euiThemeLight,
undefined,
'the-color-field',
LEGEND_TYPES.NOMINAL
);
const specForegroundLayer = vegaLiteSpec.spec.layer[0];

// column values should be escaped
expect(vegaLiteSpec.repeat).toEqual({
column: ['x\\.a', 'y\\[a\\]'],
row: ['y\\[a\\]', 'x\\.a'],
});
// raw data should not be escaped
expect(vegaLiteSpec.spec.data.values).toEqual(data);
expect(specForegroundLayer.data.values).toEqual(data);
});
});

0 comments on commit 209d813

Please sign in to comment.