@chronogrove/ui 0.80.0 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ import { render, screen } from '@testing-library/react'
2
+ import { ThemeUIProvider } from 'theme-ui'
3
+
4
+ import WidgetSection from './widget-section.js'
5
+
6
+ jest.mock('theme-ui', () => {
7
+ const actual = jest.requireActual('theme-ui')
8
+ return {
9
+ ...actual,
10
+ useThemeUI: jest.fn(() => ({ colorMode: 'default' }))
11
+ }
12
+ })
13
+
14
+ const { useThemeUI } = require('theme-ui')
15
+
16
+ describe('WidgetSection', () => {
17
+ it('renders children', () => {
18
+ useThemeUI.mockReturnValue({ colorMode: 'default' })
19
+ render(
20
+ <ThemeUIProvider theme={{}}>
21
+ <WidgetSection>
22
+ <span>content</span>
23
+ </WidgetSection>
24
+ </ThemeUIProvider>
25
+ )
26
+ expect(screen.getByText('content')).toBeInTheDocument()
27
+ })
28
+
29
+ it('sets id when provided', () => {
30
+ useThemeUI.mockReturnValue({ colorMode: 'default' })
31
+ render(
32
+ <ThemeUIProvider theme={{}}>
33
+ <WidgetSection id='w1'>x</WidgetSection>
34
+ </ThemeUIProvider>
35
+ )
36
+ expect(document.getElementById('w1')).toBeTruthy()
37
+ })
38
+
39
+ it('shows fatal error overlay', () => {
40
+ useThemeUI.mockReturnValue({ colorMode: 'dark' })
41
+ render(
42
+ <ThemeUIProvider theme={{}}>
43
+ <WidgetSection hasFatalError>inside</WidgetSection>
44
+ </ThemeUIProvider>
45
+ )
46
+ expect(screen.getByText('Something went wrong')).toBeInTheDocument()
47
+ expect(screen.getByText('inside')).toBeInTheDocument()
48
+ })
49
+
50
+ it('uses light overlay colors in light mode', () => {
51
+ useThemeUI.mockReturnValue({ colorMode: 'default' })
52
+ render(
53
+ <ThemeUIProvider theme={{}}>
54
+ <WidgetSection hasFatalError />
55
+ </ThemeUIProvider>
56
+ )
57
+ expect(screen.getByText('Something went wrong')).toBeInTheDocument()
58
+ })
59
+ })