Skip to content

Commit

Permalink
test: 修复 next 版本,不将 border width 作为 Interval 宽度。
Browse files Browse the repository at this point in the history
  • Loading branch information
stone-lyl committed Jan 13, 2023
1 parent 6ffa619 commit 3adf2d6
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions packages/s2-core/__tests__/unit/utils/g-mini-charts-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assembleDataCfg, assembleOptions } from 'tests/util';
import { getContainer } from 'tests/util/helpers';
import { forEach, map } from 'lodash';
import { data } from 'tests/data/mock-dataset.json';
import type { RangeColors } from '../../../src/common/interface/theme';
import { PivotSheet } from '@/sheet-type';
import { CellTypes, MiniChartTypes, type S2CellType } from '@/common';
Expand All @@ -11,6 +12,7 @@ import {
drawInterval,
} from '@/utils/g-mini-charts';
import type { DataCell } from '@/cell';
import { getTheme } from '@/theme';

describe('MiniCharts Utils Tests', () => {
const padding = {
Expand Down Expand Up @@ -317,27 +319,23 @@ describe('drawInterval Test', () => {
rows: ['province', 'city'],
values: ['number'],
},
data,
});

const horizontalBorderWidth =
getTheme({})?.dataCell?.cell?.horizontalBorderWidth || 1;
const options = assembleOptions({
conditions: {
interval: [
{
field: 'number',
mapping() {
return {
isCompare: true,
minValue: 0,
maxValue: 300,
fieldValue: 100,
fill: 'pink',
};
},
},
],
style: {
dataCell: {
// 计算条形图的宽度时需要去掉 border width
width: 100 + horizontalBorderWidth,
},
},
conditions: {},
});

const s2 = new PivotSheet(getContainer(), dataCfg, options);

beforeEach(() => {
s2.render();
});
Expand Down

0 comments on commit 3adf2d6

Please sign in to comment.