mirror of https://github.com/grafana/grafana
ThemeContext: Make useStyles type-aware (#26056)
PLUS: Make it more consise Add unit testpull/26086/head
parent
a2737c0896
commit
390c80d7f5
@ -0,0 +1,27 @@ |
||||
import React from 'react'; |
||||
import { config } from '@grafana/runtime'; |
||||
import { css } from 'emotion'; |
||||
import { mount } from 'enzyme'; |
||||
import { useStyles } from './ThemeContext'; |
||||
|
||||
describe('useStyles', () => { |
||||
it('passes in theme and returns style object', () => { |
||||
const Dummy: React.FC = function() { |
||||
const styles = useStyles(theme => { |
||||
expect(theme).toEqual(config.theme); |
||||
|
||||
return { |
||||
someStyle: css` |
||||
color: ${theme?.palette.critical}; |
||||
`,
|
||||
}; |
||||
}); |
||||
|
||||
expect(typeof styles.someStyle).toBe('string'); |
||||
|
||||
return <div>dummy</div>; |
||||
}; |
||||
|
||||
mount(<Dummy />); |
||||
}); |
||||
}); |
Loading…
Reference in new issue