File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
packages/react-from-markup/src/__tests__ Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1515 "lint:ts" : " tslint -c tslint.json './packages/**/*.ts*(x)'" ,
1616 "release" : " lerna version prerelease" ,
1717 "pretest" : " npm-run-all lint" ,
18- "test" : " echo \" Tests coming soon. I'm aware that's not ideal. \" "
18+ "test" : " jest "
1919 },
2020 "dependencies" : {
2121 "react" : " ^16.5.0" ,
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` reactFromMarkupContainer E2E tests Should rehydrate a basic component 1` ] = `
4+ "
5+ <div data-react-from-markup-container =\\"\\">
6+ <span>rehydrated component</span>
7+ </div>"
8+ `;
9+
10+ exports[`reactFromMarkupContainer E2E tests Should rehydrate valid HTML markup 1`] = `
11+ "
12+ <div data-react-from-markup-container=\\" \\">
13+ <p>paragraph</p>
14+ </div>"
15+ `;
Original file line number Diff line number Diff line change 1+ /* eslint-env jest */
2+ import * as React from "react" ;
3+ import reactFromMarkupContainer from ".." ;
4+
5+ describe ( "reactFromMarkupContainer E2E tests" , async ( ) => {
6+ it ( "Should rehydrate a basic component" , async ( ) => {
7+ const componentName : string = "myComponent" ;
8+
9+ const rehydrator = async ( ) => {
10+ return React . createElement ( "span" , { } , "rehydrated component" ) ;
11+ } ;
12+
13+ const rehydrators = { [ componentName ] : rehydrator } ;
14+ const documentElement = document . createElement ( "div" ) ;
15+
16+ documentElement . innerHTML = `
17+ <div data-react-from-markup-container>
18+ <div data-rehydratable="${ componentName } "></div>
19+ </div>` ;
20+
21+ await reactFromMarkupContainer ( documentElement , rehydrators , {
22+ extra : { }
23+ } ) ;
24+
25+ expect ( documentElement . innerHTML ) . toMatchSnapshot ( ) ;
26+ } ) ;
27+
28+ it ( "Should rehydrate valid HTML markup" , async ( ) => {
29+ const documentElement = document . createElement ( "div" ) ;
30+
31+ documentElement . innerHTML = `
32+ <div data-react-from-markup-container>
33+ <p>paragraph</p>
34+ </div>` ;
35+
36+ await reactFromMarkupContainer ( documentElement , { } , { extra : { } } ) ;
37+
38+ expect ( documentElement . innerHTML ) . toMatchSnapshot ( ) ;
39+ } ) ;
40+ } ) ;
You can’t perform that action at this time.
0 commit comments