-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
3,519 additions
and
1,259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,65 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import DonutFloor from '../demo/donut-floor'; | ||
import { Pie } from '@oceanbase/charts'; | ||
import type { PieConfig } from '@oceanbase/charts'; | ||
|
||
const DonutTest = (props: Partial<PieConfig>) => { | ||
const data = [ | ||
{ | ||
type: '分类一', | ||
value: 1.3, | ||
}, | ||
{ | ||
type: '分类二', | ||
value: 3.38, | ||
}, | ||
{ | ||
type: '分类三', | ||
value: 4.56, | ||
}, | ||
{ | ||
type: '分类四', | ||
value: 5.7, | ||
}, | ||
{ | ||
type: '分类五', | ||
value: 6.22, | ||
}, | ||
]; | ||
const config: PieConfig = { | ||
data, | ||
angleField: 'value', | ||
colorField: 'type', | ||
isDonut: true, | ||
...props, | ||
}; | ||
return <Pie {...config} />; | ||
}; | ||
|
||
describe('donut', () => { | ||
it('floor number', () => { | ||
const { container, asFragment } = render(<DonutFloor />); | ||
const { container, asFragment } = render(<DonutTest />); | ||
expect(container.querySelectorAll('.g2-html-annotation')?.[1].textContent).toBe('21.16'); | ||
expect(asFragment().firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('statistic title and content formatter', () => { | ||
const { container, asFragment } = render( | ||
<DonutTest | ||
statistic={{ | ||
title: { | ||
formatter: () => 'custom title', | ||
}, | ||
content: { | ||
formatter: () => 'custom content', | ||
}, | ||
}} | ||
/> | ||
); | ||
expect(container.querySelectorAll('.g2-html-annotation')?.[0].textContent).toBe('custom title'); | ||
expect(container.querySelectorAll('.g2-html-annotation')?.[1].textContent).toBe( | ||
'custom content' | ||
); | ||
expect(asFragment().firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.