11import test from 'tape' ;
22import { testSaga } from 'redux-saga-test-plan' ;
3- import { TextEncoder } from 'text-encoding' ;
4- import base64 from 'base64-js' ;
53import {
64 userDoneTyping as userDoneTypingSaga ,
75 exportGist as exportGistSaga ,
@@ -19,8 +17,8 @@ import {
1917 repoExportError ,
2018 repoExportNotDisplayed ,
2119} from '../../../src/actions/clients' ;
22- import { openWindowWithWorkaroundForChromeClosingBug } from '../../../src/util' ;
23- import { spinnerPage } from '../../../src/ templates' ;
20+ import { openWindowWithContent } from '../../../src/util' ;
21+ import spinnerPageHtml from '../../../templates/github-export.html ' ;
2422import generatePreview from '../../../src/util/generatePreview' ;
2523
2624test ( 'userDoneTyping' , ( assert ) => {
@@ -36,10 +34,7 @@ test('exportGist', (t) => {
3634 const mockWindow = { closed : false , location : { } } ;
3735 const url = 'https://gist.github.com/abc123' ;
3836 testSaga ( exportGistSaga ) .
39- next ( ) . call (
40- openWindowWithWorkaroundForChromeClosingBug ,
41- `data:text/html;charset=utf-8;base64,${ spinnerPage } ` ,
42- ) .
37+ next ( ) . call ( openWindowWithContent , spinnerPageHtml ) .
4338 next ( mockWindow ) . take ( [ 'GIST_EXPORTED' , 'GIST_EXPORT_ERROR' ] ) .
4439 next ( gistExported ( url ) ) . put ( gistExportDisplayed ( ) ) .
4540 next ( ) . isDone ( ) ;
@@ -53,10 +48,7 @@ test('exportGist', (t) => {
5348 const mockWindow = { closed : true , location : { } } ;
5449 const url = 'https://gist.github.com/abc123' ;
5550 testSaga ( exportGistSaga ) .
56- next ( ) . call (
57- openWindowWithWorkaroundForChromeClosingBug ,
58- `data:text/html;charset=utf-8;base64,${ spinnerPage } ` ,
59- ) .
51+ next ( ) . call ( openWindowWithContent , spinnerPageHtml ) .
6052 next ( mockWindow ) . take ( [ 'GIST_EXPORTED' , 'GIST_EXPORT_ERROR' ] ) .
6153 next ( gistExported ( url ) ) . put ( gistExportNotDisplayed ( url ) ) .
6254 next ( ) . isDone ( ) ;
@@ -69,10 +61,7 @@ test('exportGist', (t) => {
6961 t . test ( 'with gist export error' , ( assert ) => {
7062 const mockWindow = { closed : false , close ( ) { } } ;
7163 testSaga ( exportGistSaga ) .
72- next ( ) . call (
73- openWindowWithWorkaroundForChromeClosingBug ,
74- `data:text/html;charset=utf-8;base64,${ spinnerPage } ` ,
75- ) .
64+ next ( ) . call ( openWindowWithContent , spinnerPageHtml ) .
7665 next ( mockWindow ) . take ( [ 'GIST_EXPORTED' , 'GIST_EXPORT_ERROR' ] ) .
7766 next ( gistExportError ( new Error ( ) ) ) . call ( [ mockWindow , 'close' ] ) .
7867 next ( ) . isDone ( ) ;
@@ -86,14 +75,9 @@ test('popOutProject', (assert) => {
8675 const mockWindow = { closed : false , close ( ) { } } ;
8776 const project = { } ;
8877 const preview = '<html></html>' ;
89- const uint8array = new TextEncoder ( 'utf-8' ) . encode ( preview ) ;
90- const base64encoded = base64 . fromByteArray ( uint8array ) ;
9178 testSaga ( popOutProjectSaga , popOutProject ( project ) ) .
9279 next ( ) . call ( generatePreview , project ) .
93- next ( preview ) . call (
94- openWindowWithWorkaroundForChromeClosingBug ,
95- `data:text/html;charset=utf-8;base64,${ base64encoded } ` ,
96- ) .
80+ next ( preview ) . call ( openWindowWithContent , preview ) .
9781 next ( mockWindow ) . isDone ( ) ;
9882 assert . end ( ) ;
9983} ) ;
@@ -103,10 +87,7 @@ test('exportRepo', (t) => {
10387 const mockWindow = { closed : false , location : { } } ;
10488 const url = 'https://popcode-mat.github.io/my-popcode-repo' ;
10589 testSaga ( exportRepoSaga ) .
106- next ( ) . call (
107- openWindowWithWorkaroundForChromeClosingBug ,
108- `data:text/html;charset=utf-8;base64,${ spinnerPage } ` ,
109- ) .
90+ next ( ) . call ( openWindowWithContent , spinnerPageHtml ) .
11091 next ( mockWindow ) . take ( [ 'REPO_EXPORTED' , 'REPO_EXPORT_ERROR' ] ) .
11192 next ( repoExported ( url ) ) . put ( repoExportDisplayed ( ) ) .
11293 next ( ) . isDone ( ) ;
@@ -120,10 +101,7 @@ test('exportRepo', (t) => {
120101 const mockWindow = { closed : true , location : { } } ;
121102 const url = 'https://popcode-mat.github.io/my-popcode-repo' ;
122103 testSaga ( exportRepoSaga ) .
123- next ( ) . call (
124- openWindowWithWorkaroundForChromeClosingBug ,
125- `data:text/html;charset=utf-8;base64,${ spinnerPage } ` ,
126- ) .
104+ next ( ) . call ( openWindowWithContent , spinnerPageHtml ) .
127105 next ( mockWindow ) . take ( [ 'REPO_EXPORTED' , 'REPO_EXPORT_ERROR' ] ) .
128106 next ( repoExported ( url ) ) . put ( repoExportNotDisplayed ( url ) ) .
129107 next ( ) . isDone ( ) ;
@@ -136,10 +114,7 @@ test('exportRepo', (t) => {
136114 t . test ( 'with repo export error' , ( assert ) => {
137115 const mockWindow = { closed : false , close ( ) { } } ;
138116 testSaga ( exportRepoSaga ) .
139- next ( ) . call (
140- openWindowWithWorkaroundForChromeClosingBug ,
141- `data:text/html;charset=utf-8;base64,${ spinnerPage } ` ,
142- ) .
117+ next ( ) . call ( openWindowWithContent , spinnerPageHtml ) .
143118 next ( mockWindow ) . take ( [ 'REPO_EXPORTED' , 'REPO_EXPORT_ERROR' ] ) .
144119 next ( repoExportError ( new Error ( ) ) ) . call ( [ mockWindow , 'close' ] ) .
145120 next ( ) . isDone ( ) ;
0 commit comments