2020-05-05 21:59:32 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2021-02-04 03:12:39 +01:00
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
|
|
* 2.0.
|
2020-05-05 21:59:32 +02:00
|
|
|
*/
|
|
|
|
|
2020-11-04 11:27:52 +01:00
|
|
|
import { PaletteOutput } from 'src/plugins/charts/public';
|
2020-05-05 21:59:32 +02:00
|
|
|
import { DataType } from '../types';
|
|
|
|
import { suggestions } from './suggestions';
|
2020-11-24 09:56:56 +01:00
|
|
|
import { PieVisualizationState } from './types';
|
2020-05-05 21:59:32 +02:00
|
|
|
|
|
|
|
describe('suggestions', () => {
|
|
|
|
describe('pie', () => {
|
|
|
|
it('should reject multiple layer suggestions', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first', 'second'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reject when layer is different', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['second'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reject when currently active and unchanged data', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [],
|
|
|
|
changeType: 'unchanged',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
shape: 'pie',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: [],
|
|
|
|
metric: 'a',
|
|
|
|
numberDisplay: 'hidden',
|
|
|
|
categoryDisplay: 'default',
|
|
|
|
legendDisplay: 'default',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reject when table is reordered', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [],
|
|
|
|
changeType: 'reorder',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2020-11-24 09:56:56 +01:00
|
|
|
it('should reject date operations', () => {
|
2020-05-05 21:59:32 +02:00
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
2020-08-27 00:27:40 +02:00
|
|
|
operation: {
|
|
|
|
label: 'Days',
|
|
|
|
dataType: 'date' as DataType,
|
|
|
|
isBucketed: true,
|
|
|
|
scale: 'interval',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2020-11-24 09:56:56 +01:00
|
|
|
it('should reject histogram operations', () => {
|
2020-08-27 00:27:40 +02:00
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: {
|
|
|
|
label: 'Durations',
|
|
|
|
dataType: 'number' as DataType,
|
|
|
|
isBucketed: true,
|
|
|
|
scale: 'interval',
|
|
|
|
},
|
2020-05-05 21:59:32 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2020-11-24 09:56:56 +01:00
|
|
|
it('should reject when there are too many buckets', () => {
|
2020-05-05 21:59:32 +02:00
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
2020-11-24 09:56:56 +01:00
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
2020-05-05 21:59:32 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
2020-11-24 09:56:56 +01:00
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'd',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
2020-05-05 21:59:32 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2020-11-24 09:56:56 +01:00
|
|
|
it('should reject when there are too many metrics', () => {
|
2020-05-05 21:59:32 +02:00
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'd',
|
2020-11-24 09:56:56 +01:00
|
|
|
operation: { label: 'Avg', dataType: 'number' as DataType, isBucketed: false },
|
2020-05-05 21:59:32 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2020-11-24 09:56:56 +01:00
|
|
|
it('should reject if there are no buckets and it is not a specific chart type switch', () => {
|
2020-05-05 21:59:32 +02:00
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
2020-11-24 09:56:56 +01:00
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
2020-05-05 21:59:32 +02:00
|
|
|
},
|
2020-11-24 09:56:56 +01:00
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: {} as PieVisualizationState,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reject if there are no metrics and it is not a specific chart type switch', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
2020-05-05 21:59:32 +02:00
|
|
|
{
|
2020-11-24 09:56:56 +01:00
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: true },
|
2020-05-05 21:59:32 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
2020-11-24 09:56:56 +01:00
|
|
|
state: {} as PieVisualizationState,
|
2020-05-05 21:59:32 +02:00
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2020-11-24 09:56:56 +01:00
|
|
|
it('should hide suggestions when there are no buckets', () => {
|
|
|
|
const currentSuggestions = suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
});
|
|
|
|
expect(currentSuggestions).toHaveLength(3);
|
|
|
|
expect(currentSuggestions.every((s) => s.hide)).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide suggestions when there are no metrics', () => {
|
|
|
|
const currentSuggestions = suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
});
|
|
|
|
expect(currentSuggestions).toHaveLength(3);
|
|
|
|
expect(currentSuggestions.every((s) => s.hide)).toEqual(true);
|
|
|
|
});
|
|
|
|
|
2020-05-05 21:59:32 +02:00
|
|
|
it('should suggest a donut chart as initial state when only one bucket', () => {
|
|
|
|
const results = suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(results).toContainEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
state: expect.objectContaining({ shape: 'donut' }),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should suggest a pie chart as initial state when more than one bucket', () => {
|
|
|
|
const results = suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(results).toContainEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
state: expect.objectContaining({ shape: 'pie' }),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2020-11-04 11:27:52 +01:00
|
|
|
it('should keep passed in palette', () => {
|
|
|
|
const mainPalette: PaletteOutput = { type: 'palette', name: 'mock' };
|
|
|
|
const results = suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: undefined,
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
mainPalette,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(results[0].state.palette).toEqual(mainPalette);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should keep the layer settings and palette when switching from treemap', () => {
|
|
|
|
const palette: PaletteOutput = { type: 'palette', name: 'mock' };
|
2020-05-05 21:59:32 +02:00
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'unchanged',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
shape: 'treemap',
|
2020-11-04 11:27:52 +01:00
|
|
|
palette,
|
2020-05-05 21:59:32 +02:00
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: ['a'],
|
|
|
|
metric: 'b',
|
|
|
|
|
|
|
|
numberDisplay: 'hidden',
|
|
|
|
categoryDisplay: 'inside',
|
|
|
|
legendDisplay: 'show',
|
|
|
|
percentDecimals: 0,
|
|
|
|
nestedLegend: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toContainEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
state: {
|
|
|
|
shape: 'donut',
|
2020-11-04 11:27:52 +01:00
|
|
|
palette,
|
2020-05-05 21:59:32 +02:00
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: ['a'],
|
|
|
|
metric: 'b',
|
|
|
|
|
|
|
|
numberDisplay: 'hidden',
|
|
|
|
categoryDisplay: 'inside',
|
|
|
|
legendDisplay: 'show',
|
|
|
|
percentDecimals: 0,
|
|
|
|
nestedLegend: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('treemap', () => {
|
|
|
|
it('should reject when currently active and unchanged data', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [],
|
|
|
|
changeType: 'unchanged',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
shape: 'treemap',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: [],
|
|
|
|
metric: 'a',
|
|
|
|
|
|
|
|
numberDisplay: 'hidden',
|
|
|
|
categoryDisplay: 'default',
|
|
|
|
legendDisplay: 'default',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reject when there are too many buckets being added', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'd',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'extended',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
shape: 'treemap',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: ['a', 'b'],
|
|
|
|
metric: 'e',
|
|
|
|
numberDisplay: 'value',
|
|
|
|
categoryDisplay: 'default',
|
|
|
|
legendDisplay: 'default',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reject when there are too many metrics', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'c',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'd',
|
|
|
|
operation: { label: 'Avg', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'e',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'initial',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
shape: 'treemap',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: ['a', 'b'],
|
|
|
|
metric: 'e',
|
|
|
|
numberDisplay: 'percent',
|
|
|
|
categoryDisplay: 'default',
|
|
|
|
legendDisplay: 'default',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should keep the layer settings when switching from pie', () => {
|
|
|
|
expect(
|
|
|
|
suggestions({
|
|
|
|
table: {
|
|
|
|
layerId: 'first',
|
|
|
|
isMultiRow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
columnId: 'a',
|
|
|
|
operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
columnId: 'b',
|
|
|
|
operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
changeType: 'unchanged',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
shape: 'pie',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: ['a'],
|
|
|
|
metric: 'b',
|
|
|
|
|
|
|
|
numberDisplay: 'hidden',
|
|
|
|
categoryDisplay: 'inside',
|
|
|
|
legendDisplay: 'show',
|
|
|
|
percentDecimals: 0,
|
|
|
|
nestedLegend: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keptLayerIds: ['first'],
|
|
|
|
})
|
|
|
|
).toContainEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
state: {
|
|
|
|
shape: 'treemap',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
layerId: 'first',
|
|
|
|
groups: ['a'],
|
|
|
|
metric: 'b',
|
|
|
|
|
|
|
|
numberDisplay: 'hidden',
|
2020-05-06 22:45:32 +02:00
|
|
|
categoryDisplay: 'default', // This is changed
|
2020-05-05 21:59:32 +02:00
|
|
|
legendDisplay: 'show',
|
|
|
|
percentDecimals: 0,
|
|
|
|
nestedLegend: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|