-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove flatten Add prod mode tests Add really crazy nesting test * Update snapshots for nested array test. * Add prod-mode snapshots * rework handleInterpolation a bit.
- Loading branch information
Showing
7 changed files
with
214 additions
and
37 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
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
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
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
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,14 @@ | ||
{ | ||
"presets": [ | ||
"flow", | ||
"env", | ||
"react" | ||
], | ||
"plugins": [ | ||
[ | ||
"transform-define", | ||
{ | ||
"process.env.NODE_ENV": "production" | ||
} | ||
], ["../../../../babel-plugin-emotion-test"], "codegen"] | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/emotion/test/prod-mode/__snapshots__/prod-mode.test.js.snap
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,74 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`production mode production mode basic 1`] = ` | ||
.glamor-0 { | ||
color: yellow; | ||
} | ||
.glamor-0 .some-class { | ||
display: -webkit-box; | ||
display: -webkit-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
} | ||
.glamor-0 .some-class .some-other-class { | ||
background-color: hotpink; | ||
} | ||
@media (max-width:600px) { | ||
.glamor-0 .some-class { | ||
background-color: pink; | ||
} | ||
} | ||
<div | ||
className="glamor-0" | ||
> | ||
<div | ||
className="some-class" | ||
> | ||
<div | ||
className="some-other-class" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`production mode production mode nested media queries 1`] = ` | ||
"@media (max-width:600px) { | ||
.css-acogag h1 { | ||
font-size: 1.4rem; | ||
} | ||
} | ||
@media (max-width:400px),(max-height:420px) { | ||
.css-acogag h1 { | ||
font-size: 1.1rem; | ||
} | ||
}" | ||
`; | ||
|
||
exports[`production mode production mode nested styles 1`] = ` | ||
".css-s7aswl { | ||
color: blue; | ||
} | ||
.css-s7aswl:hover { | ||
color: green; | ||
} | ||
.css-s7aswl:hover .name { | ||
color: amethyst; | ||
} | ||
.css-s7aswl:hover .name:focus { | ||
color: burlywood; | ||
} | ||
@media (min-width:420px) { | ||
.css-s7aswl:hover .name:focus { | ||
color: rebeccapurple; | ||
} | ||
}" | ||
`; |
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,74 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import { css, sheet, flush } from 'emotion' | ||
|
||
describe('production mode', () => { | ||
afterEach(() => flush()) | ||
test('production mode basic', () => { | ||
const cls1 = css` | ||
color: yellow; | ||
& .some-class { | ||
display: flex; | ||
& .some-other-class { | ||
background-color: hotpink; | ||
} | ||
@media (max-width: 600px) { | ||
background-color: pink; | ||
} | ||
} | ||
` | ||
const tree = renderer | ||
.create( | ||
<div className={cls1}> | ||
<div className="some-class"> | ||
<div className="some-other-class" /> | ||
</div> | ||
</div> | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('production mode nested styles', () => { | ||
const mq = [ | ||
'@media(min-width: 420px)', | ||
'@media(min-width: 640px)', | ||
'@media(min-width: 960px)' | ||
] | ||
|
||
css({ | ||
color: 'blue', | ||
'&:hover': { | ||
'& .name': { | ||
color: 'amethyst', | ||
'&:focus': { | ||
color: 'burlywood', | ||
[mq[0]]: { | ||
color: 'rebeccapurple' | ||
} | ||
} | ||
}, | ||
color: 'green' | ||
} | ||
}) | ||
expect(sheet).toMatchSnapshot() | ||
}) | ||
|
||
test('production mode nested media queries', () => { | ||
css` | ||
@media (max-width: 600px) { | ||
h1 { | ||
font-size: 1.4rem; | ||
} | ||
} | ||
@media (max-width: 400px), (max-height: 420px) { | ||
h1 { | ||
font-size: 1.1rem; | ||
} | ||
} | ||
` | ||
|
||
expect(sheet).toMatchSnapshot() | ||
}) | ||
}) |