import { h, createContext, render } from 'preact'; import { useContext } from 'preact/hooks'; import { setup, extractCss } from 'goober'; import { createGlobalStyles } from '../index'; describe('createGlobalStyles', () => { it('regular', () => { setup(h); const target = document.createElement('div'); const GlobalStyle = createGlobalStyles` html, body { background: dodgerblue; } `; render(
, target ); expect(extractCss()).toMatchSnapshot(); expect(target.innerHTML).toMatchSnapshot(); }); it('with theme', () => { const ThemeContext = createContext(); const useTheme = () => useContext(ThemeContext); setup(h, null, useTheme); const target = document.createElement('div'); const GlobalStyle = createGlobalStyles` html, body { margin: 0; background: ${(props) => props.theme.color}; } `; render(
, target ); expect(extractCss()).toMatchSnapshot(); expect(target.innerHTML).toMatchSnapshot(); }); });