forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(style): throw if there is no theme (apache#761)
* fix(style): throw if there is no theme * tests * factor out SupersetTheme type * fix test
- Loading branch information
1 parent
1d3e278
commit 0a0432c
Showing
4 changed files
with
65 additions
and
21 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
18 changes: 0 additions & 18 deletions
18
...-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-style/test/index.test.ts
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...frontend/temporary_superset_ui/superset-ui/packages/superset-ui-style/test/index.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,44 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import styled, { supersetTheme, SupersetThemeProps, useTheme, ThemeProvider } from '../src'; | ||
|
||
describe('@superset-ui/style package', () => { | ||
it('exports a theme', () => { | ||
expect(typeof supersetTheme).toBe('object'); | ||
}); | ||
|
||
it('exports styled component templater', () => { | ||
expect(typeof styled.div).toBe('function'); | ||
}); | ||
|
||
it('exports SupersetThemeProps', () => { | ||
const props: SupersetThemeProps = { | ||
theme: supersetTheme, | ||
}; | ||
expect(typeof props).toBe('object'); | ||
}); | ||
|
||
describe('useTheme()', () => { | ||
it('returns the theme', () => { | ||
function ThemeUser() { | ||
expect(useTheme()).toStrictEqual(supersetTheme); | ||
return <div>test</div>; | ||
} | ||
mount(<ThemeUser />, { | ||
wrappingComponent: ({ children }) => ( | ||
<ThemeProvider theme={supersetTheme}>{children}</ThemeProvider> | ||
), | ||
}); | ||
}); | ||
|
||
it('throws when a theme is not present', () => { | ||
function ThemeUser() { | ||
expect(useTheme).toThrow(/could not find a ThemeContext/); | ||
return <div>test</div>; | ||
} | ||
mount(<ThemeUser />, { | ||
wrappingComponent: ({ children }) => <div>{children}</div>, | ||
}); | ||
}); | ||
}); | ||
}); |