File tree Expand file tree Collapse file tree 9 files changed +47
-6
lines changed
preact-component-bundle-false/src
react-component-bundle-false/src/components/CounterButton
react-component-bundle/src/components/CounterButton
tests/e2e/react-component Expand file tree Collapse file tree 9 files changed +47
-6
lines changed Original file line number Diff line number Diff line change 11import type { FunctionComponent } from 'preact' ;
2+ import logo from '../../assets/logo.svg' ;
23import styles from './index.module.scss' ;
34
45interface CounterButtonProps {
@@ -10,7 +11,12 @@ export const CounterButton: FunctionComponent<CounterButtonProps> = ({
1011 onClick,
1112 label,
1213} ) => (
13- < button type = "button" className = { styles . button } onClick = { onClick } >
14+ < button
15+ type = "button"
16+ className = { `${ styles . button } counter-button` }
17+ onClick = { onClick }
18+ >
19+ < img src = { logo } alt = "react" />
1420 { label }
1521 </ button >
1622) ;
Original file line number Diff line number Diff line change @@ -2,3 +2,8 @@ declare module '*.module.scss' {
22 const classes : { [ key : string ] : string } ;
33 export default classes ;
44}
5+
6+ declare module '*.svg' {
7+ const url : string ;
8+ export default url ;
9+ }
Original file line number Diff line number Diff line change 1+ .counter-title {
2+ width : 100px ;
3+ height : 100px ;
4+ background : no-repeat url (' ./assets/logo.svg' );
5+ background-size : cover ;
6+ }
7+
18.counter-text {
29 font-size : 50px ;
310}
Original file line number Diff line number Diff line change 11.button {
2- background : url ( ' ../../assets/logo.svg ' ) no-repeat ;
2+ background : yellow ;
33}
Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
1111 onClick,
1212 label,
1313} ) => (
14- < button type = "button" className = { styles . button } onClick = { onClick } >
14+ < button
15+ type = "button"
16+ className = { `${ styles . button } counter-button` }
17+ onClick = { onClick }
18+ >
1519 < img src = { logo } alt = "react" />
1620 { label }
1721 </ button >
Original file line number Diff line number Diff line change 11.button {
2- background : url ( ' ../../assets/logo.svg ' ) no-repeat ;
2+ background : yellow ;
33}
Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
1111 onClick,
1212 label,
1313} ) => (
14- < button type = "button" className = { styles . button } onClick = { onClick } >
14+ < button
15+ type = "button"
16+ className = { `${ styles . button } counter-button` }
17+ onClick = { onClick }
18+ >
1519 < img src = { logo } alt = "react" />
1620 { label }
1721 </ button >
Original file line number Diff line number Diff line change @@ -40,7 +40,15 @@ async function assetShouldWork(page: Page) {
4040 assert ( h1El ) ;
4141 expect ( h1El ) . toHaveCSS ( 'background' , / s t a t i c \/ s v g \/ l o g o / ) ;
4242
43- // TODO: asset in js
43+ // asset by import url from './assets/logo.svg'
44+ const imgEls = await page . $$ ( '.counter-button>img' ) ;
45+ expect ( imgEls ) . toHaveLength ( 2 ) ;
46+ const srcList = await Promise . all (
47+ imgEls . map ( ( imgEl ) => imgEl . getAttribute ( 'src' ) ) ,
48+ )
49+ for ( const src of srcList ) {
50+ expect ( src ) . toMatch ( / s t a t i c \/ s v g \/ l o g o / ) ;
51+ }
4452}
4553
4654test ( 'should render example "react-component-bundle" successfully' , async ( {
You can’t perform that action at this time.
0 commit comments