Skip to content

Commit

Permalink
fix(api): auotFit sizeOf width > auto width > default width (#6013)
Browse files Browse the repository at this point in the history
* fix(api): auotFit sizeOf width > auto width > default width

* fix(api): auotFit sizeOf width > auto width > default width

---------

Co-authored-by: wb-xcf804241 <wb-xcf804241@alibaba-inc.com>
  • Loading branch information
ai-qing-hai and wb-xcf804241 committed Jan 10, 2024
1 parent 039716f commit 0f992d2
Show file tree
Hide file tree
Showing 8 changed files with 3,308 additions and 3 deletions.
24 changes: 24 additions & 0 deletions __tests__/integration/api-chart-auto-fit-height.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { chartAutoFitHeight as render } from '../plots/api';
import { createNodeGCanvas } from './utils/createNodeGCanvas';
import { sleep } from './utils/sleep';
import { kebabCase } from './utils/kebabCase';
import './utils/useSnapshotMatchers';

describe('chart.options.autoFit', () => {
const dir = `${__dirname}/snapshots/api/${kebabCase(render.name)}`;
const canvas = createNodeGCanvas(800, 500);

it('chart({ autoFit: true, height: 200 }) should fit parent container width and custom height', async () => {
const { finished } = render({
canvas,
container: document.createElement('div'),
});
await finished;
await sleep(20);
await expect(canvas).toMatchDOMSnapshot(dir, 'step0');
});

afterAll(() => {
canvas?.destroy();
});
});
25 changes: 25 additions & 0 deletions __tests__/integration/api-chart-auto-fit-width.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { chartAutoFitWidth as render } from '../plots/api';
import { createNodeGCanvas } from './utils/createNodeGCanvas';
import { sleep } from './utils/sleep';
import { kebabCase } from './utils/kebabCase';
import './utils/useSnapshotMatchers';

describe('chart.options.autoFit', () => {
const dir = `${__dirname}/snapshots/api/${kebabCase(render.name)}`;
const canvas = createNodeGCanvas(800, 500);

it('chart({ autoFit: true, width: 200 }) should fit parent container height and custom width', async () => {
const { finished } = render({
canvas,
container: document.createElement('div'),
});

await finished;
await sleep(20);
await expect(canvas).toMatchDOMSnapshot(dir, 'step0');
});

afterAll(() => {
canvas?.destroy();
});
});

0 comments on commit 0f992d2

Please sign in to comment.