-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for not and fix a couple of bugs
- Loading branch information
1 parent
a3f0add
commit caeab5e
Showing
2 changed files
with
87 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import '@compiled/css-in-js'; | ||
|
||
it('should detect styles', () => { | ||
const { getByText } = render( | ||
<div | ||
css={{ | ||
fontSize: '12px', | ||
}}> | ||
hello world | ||
</div> | ||
); | ||
|
||
expect(getByText('hello world')).toHaveCompiledCss('font-size', '12px'); | ||
}); | ||
|
||
it('should detect missing styles', () => { | ||
const { getByText } = render(<div css={{ fontSize: '12px' }}>hello world</div>); | ||
|
||
expect(getByText('hello world')).not.toHaveCompiledCss('color', 'blue'); | ||
}); | ||
|
||
it('should detect multiple styles', () => { | ||
const { getByText } = render(<div css={{ fontSize: '12px', color: 'blue' }}>hello world</div>); | ||
|
||
expect(getByText('hello world')).toHaveCompiledCss({ | ||
fontSize: '12px', | ||
color: 'blue', | ||
}); | ||
}); | ||
|
||
it('should detect single missing styles', () => { | ||
const { getByText } = render(<div css={{ fontSize: '12px', color: 'blue' }}>hello world</div>); | ||
|
||
expect(getByText('hello world')).not.toHaveCompiledCss({ | ||
zindex: '9999', | ||
}); | ||
}); | ||
|
||
it('should detect multiple missing styles', () => { | ||
const { getByText } = render(<div css={{ fontSize: '12px', color: 'blue' }}>hello world</div>); | ||
|
||
expect(getByText('hello world')).not.toHaveCompiledCss({ | ||
backgroundColor: 'yellow', | ||
zindex: '9999', | ||
}); | ||
}); | ||
|
||
it('should detect evaluated rule from array styles', () => { | ||
const base = { fontSize: 12 }; | ||
const next = ` font-size: 15px; `; | ||
|
||
const { getByText } = render(<div css={[base, next]}>hello world</div>); | ||
expect(getByText('hello world')).toHaveCompiledCss('font-size', '15px'); | ||
expect(getByText('hello world')).toHaveCompiledCss('font-size', '12px'); | ||
}); |
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