-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use css style on component testing (#2701)
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
|
||
const css = require('fs').readFileSync( | ||
`${__dirname}/../../../../../priv/static/assets/app.css`, | ||
'utf8' | ||
); | ||
|
||
/** | ||
* Prepend the application global css in a <style> element. | ||
* It's meant to be used in component testing when css classes must be resolved. | ||
* | ||
* @example | ||
* | ||
* render( | ||
* <WithStyle> | ||
* <Elem /> | ||
* </WithStyle> | ||
* ); | ||
*/ | ||
export function WithStyle({ children }) { | ||
return ( | ||
<> | ||
<style>{css}</style> | ||
{children} | ||
</> | ||
); | ||
} |
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