Skip to content

Commit

Permalink
fix(styled-components): fix createGlobalStyle
Browse files Browse the repository at this point in the history
Closes #22
  • Loading branch information
gregberge committed Jun 11, 2019
1 parent 6dc0f19 commit 8c5d386
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/styled-components/src/createGlobalStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { createGlobalStyle as scCreateGlobalStyle } from 'styled-components'
import { css } from './css'

export const createGlobalStyle = (...args) => {
return scCreateGlobalStyle(css(...args))
return scCreateGlobalStyle([css(...args)])
}
26 changes: 24 additions & 2 deletions packages/styled-components/src/createGlobalStyle.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react'
import 'jest-dom/extend-expect'
import { render } from '@testing-library/react'
import { createGlobalStyle } from '.'
import { render, cleanup } from '@testing-library/react'
import { createGlobalStyle, css } from '.'

afterEach(cleanup)

describe('#createGlobalStyle', () => {
it('injects global styles', () => {
Expand All @@ -20,4 +22,24 @@ describe('#createGlobalStyle', () => {
margin: 8px;
`)
})

it('supports css tag', () => {
const style = css`
.margin {
margin: ${3};
}
`
const GlobalStyle = createGlobalStyle`
${style}
`
const { container } = render(
<>
<GlobalStyle />
<div className="margin" />
</>,
)
expect(container.firstChild).toHaveStyle(`
margin: 16px;
`)
})
})

0 comments on commit 8c5d386

Please sign in to comment.