Skip to content

Commit

Permalink
test(core): add tests for css prop
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus committed Jul 19, 2021
1 parent ea59890 commit 3633dc9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ module.exports = {

// TypeScript checks this
'no-undef': 'off',
'no-lone-blocks': 'off',
},
}
28 changes: 27 additions & 1 deletion packages/core/test/react-jsx.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-lone-blocks */

/** @jsx jsx */
import { renderJSON, NotHas, Assert } from '@theme-ui/test-utils'
import { renderJSON, NotHas, Assert, expecter } from '@theme-ui/test-utils'

import { jsx, SxProp, ThemeUIJSX } from '../src'

Expand All @@ -26,6 +26,32 @@ describe('JSX', () => {
)
).toMatchSnapshot()
})

test('accepts css prop', () => {
const expectSnippet = expecter(
`/** @jsxImportSource @theme-ui/core */
export {}`,
{ jsx: false }
)

expectSnippet(`const _1 = <div css={{ color: 'red' }} />`).toSucceed()

expectSnippet(
`<div
css={(t) => {
const _t = t;
return {}
}}
/>`
).toInfer('_t', 'Theme')

expectSnippet(
`import { css } from '@emotion/react'
const TestComponent = () => <div css={css\`display: block;\`} />`
).toSucceed()
})
})

{
Expand Down

0 comments on commit 3633dc9

Please sign in to comment.