@@ -3,31 +3,68 @@ const TEST_ID = `sub-title`
33const message = `This is a sub-title`
44
55describe ( `hot reloading non-js file` , ( ) => {
6- beforeEach ( ( ) => {
7- cy . exec (
8- `npm run update -- --file content/2018-12-14-hello-world.md --replacements "${ message } :%${ TEMPLATE } %" --exact`
9- )
10- cy . wait ( 1000 )
6+ describe ( `markdown` , ( ) => {
7+ beforeEach ( ( ) => {
8+ cy . exec (
9+ `npm run update -- --file content/2018-12-14-hello-world.md --replacements "${ message } :%${ TEMPLATE } %" --exact`
10+ )
11+ cy . wait ( 1000 )
12+
13+ cy . visit ( `/2018-12-14-hello-world/` ) . waitForRouteChange ( )
14+
15+ cy . wait ( 1000 )
16+ } )
17+
18+ it ( `displays placeholder content on launch` , ( ) => {
19+ cy . getTestElement ( TEST_ID ) . invoke ( `text` ) . should ( `contain` , TEMPLATE )
20+ } )
21+
22+ it ( `hot reloads with new content` , ( ) => {
23+ cy . getTestElement ( TEST_ID ) . invoke ( `text` ) . should ( `contain` , TEMPLATE )
24+
25+ cy . exec (
26+ `npm run update -- --file content/2018-12-14-hello-world.md --replacements "${ TEMPLATE } :${ message } "`
27+ )
28+
29+ // wait for socket.io to update
30+ cy . wait ( 5000 )
31+
32+ cy . getTestElement ( TEST_ID ) . invoke ( `text` ) . should ( `eq` , message )
33+ } )
34+ } )
1135
12- cy . visit ( `/2018-12-14-hello-world/` ) . waitForRouteChange ( )
36+ describe ( `image` , ( ) => {
37+ beforeEach ( ( ) => {
38+ cy . visit ( `/md-image/` ) . waitForRouteChange ( )
39+ cy . wait ( 1000 )
1340
14- cy . wait ( 1000 )
15- } )
41+ cy . exec (
42+ `npm run update -- --file src/images/image.png --copy "src/images/original.png"`
43+ )
44+ cy . wait ( 2000 )
45+ } )
1646
17- it ( `displays placeholder content on launch` , ( ) => {
18- cy . getTestElement ( TEST_ID ) . invoke ( `text` ) . should ( `contain` , TEMPLATE )
19- } )
47+ const runImageSnapshot = ( snapshotName ) => {
48+ cy . get ( `.gatsby-resp-image-wrapper` )
49+ . find ( "img" )
50+ . each ( ( $el , i ) => {
51+ cy . wrap ( $el ) . matchImageSnapshot ( `${ snapshotName } -${ i } ` )
52+ } )
53+ }
2054
21- it ( `hot reloads with new content` , ( ) => {
22- cy . getTestElement ( TEST_ID ) . invoke ( `text` ) . should ( `contain` , TEMPLATE )
55+ it ( `displays original content on launch` , ( ) => {
56+ runImageSnapshot ( `non-js-file--image-original` )
57+ } )
2358
24- cy . exec (
25- `npm run update -- --file content/2018-12-14-hello-world.md --replacements "${ TEMPLATE } :${ message } "`
26- )
59+ it ( `hot reloads with new content` , ( ) => {
60+ cy . exec (
61+ `npm run update -- --file src/images/image.png --copy "src/images/new.png"`
62+ )
2763
28- // wati for socket.io to update
29- cy . wait ( 5000 )
64+ // wait for socket.io to update
65+ cy . wait ( 5000 )
3066
31- cy . getTestElement ( TEST_ID ) . invoke ( `text` ) . should ( `eq` , message )
67+ runImageSnapshot ( `non-js-file--image-new` )
68+ } )
3269 } )
3370} )
0 commit comments