-
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.
test(chart): Add test cases for ChartProvider theme
- Loading branch information
1 parent
c445fbf
commit d967d35
Showing
10 changed files
with
126 additions
and
30 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
64 changes: 64 additions & 0 deletions
64
packages/charts/src/ChartProvider/__tests__/theme.test.tsx
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { ChartProvider, useTheme } from '@oceanbase/charts'; | ||
|
||
describe('ChartProvider theme', () => { | ||
it('default theme', () => { | ||
const Child = () => { | ||
const themeConfig = useTheme(); | ||
expect(themeConfig.theme).toBe('light'); | ||
expect(themeConfig.defaultColor).toBe('#4C96FF'); | ||
return <div />; | ||
}; | ||
render( | ||
<ChartProvider> | ||
<Child /> | ||
</ChartProvider> | ||
); | ||
}); | ||
|
||
it('light theme', () => { | ||
const Child = () => { | ||
const themeConfig = useTheme(); | ||
expect(themeConfig.theme).toBe('light'); | ||
expect(themeConfig.defaultColor).toBe('#4C96FF'); | ||
return <div />; | ||
}; | ||
render( | ||
<ChartProvider theme="light"> | ||
<Child /> | ||
</ChartProvider> | ||
); | ||
}); | ||
|
||
it('dark theme', () => { | ||
const Child = () => { | ||
const themeConfig = useTheme(); | ||
expect(themeConfig.theme).toBe('dark'); | ||
expect(themeConfig.defaultColor).toBe('#4D97FF'); | ||
return <div />; | ||
}; | ||
render( | ||
<ChartProvider theme="dark"> | ||
<Child /> | ||
</ChartProvider> | ||
); | ||
}); | ||
|
||
it('custom theme config', () => { | ||
const Child = () => { | ||
const themeConfig = useTheme(); | ||
expect(themeConfig.theme).toBe('custom-theme'); | ||
expect(themeConfig.defaultColor).toBe('#ff0000'); | ||
expect(themeConfig.subColor).toBe('#00ff00'); | ||
return <div />; | ||
}; | ||
render( | ||
<ChartProvider | ||
theme={{ theme: 'custom-theme', defaultColor: '#ff0000', subColor: '#00ff00' }} | ||
> | ||
<Child /> | ||
</ChartProvider> | ||
); | ||
}); | ||
}); |
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
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