@@ -25,6 +25,7 @@ describe("Downloading project with name set", () => {
25
25
project : {
26
26
name : "My epic project" ,
27
27
identifier : "hello-world-project" ,
28
+ instructions : "print hello world to the console" ,
28
29
components : [
29
30
{
30
31
name : "main" ,
@@ -53,6 +54,18 @@ describe("Downloading project with name set", () => {
53
54
expect ( downloadButton ) . toBeInTheDocument ( ) ;
54
55
} ) ;
55
56
57
+ test ( "Clicking download zips instructions" , async ( ) => {
58
+ fireEvent . click ( downloadButton ) ;
59
+ const JSZipInstance = JSZip . mock . instances [ 0 ] ;
60
+ const mockFile = JSZipInstance . file ;
61
+ await waitFor ( ( ) =>
62
+ expect ( mockFile ) . toHaveBeenCalledWith (
63
+ "INSTRUCTIONS.md" ,
64
+ "print hello world to the console" ,
65
+ ) ,
66
+ ) ;
67
+ } ) ;
68
+
56
69
test ( "Clicking download zips project file content" , async ( ) => {
57
70
fireEvent . click ( downloadButton ) ;
58
71
const JSZipInstance = JSZip . mock . instances [ 0 ] ;
@@ -123,3 +136,48 @@ describe("Downloading project with no name set", () => {
123
136
) ;
124
137
} ) ;
125
138
} ) ;
139
+
140
+ describe ( "Downloading project with no instructions set" , ( ) => {
141
+ let downloadButton ;
142
+
143
+ beforeEach ( ( ) => {
144
+ JSZip . mockClear ( ) ;
145
+ const middlewares = [ ] ;
146
+ const mockStore = configureStore ( middlewares ) ;
147
+ const initialState = {
148
+ editor : {
149
+ project : {
150
+ name : "My epic project" ,
151
+ identifier : "hello-world-project" ,
152
+ components : [
153
+ {
154
+ name : "main" ,
155
+ extension : "py" ,
156
+ content : "" ,
157
+ } ,
158
+ ] ,
159
+ image_list : [ ] ,
160
+ } ,
161
+ } ,
162
+ } ;
163
+ const store = mockStore ( initialState ) ;
164
+ render (
165
+ < Provider store = { store } >
166
+ < DownloadButton buttonText = "Download" Icon = { ( ) => { } } />
167
+ </ Provider > ,
168
+ ) ;
169
+ downloadButton = screen . queryByText ( "Download" ) . parentElement ;
170
+ } ) ;
171
+
172
+ test ( "Clicking download button does not zip instructions" , async ( ) => {
173
+ fireEvent . click ( downloadButton ) ;
174
+ const JSZipInstance = JSZip . mock . instances [ 0 ] ;
175
+ const mockFile = JSZipInstance . file ;
176
+ await waitFor ( ( ) =>
177
+ expect ( mockFile ) . not . toHaveBeenCalledWith (
178
+ "INSTRUCTIONS.md" ,
179
+ expect . anything ( ) ,
180
+ ) ,
181
+ ) ;
182
+ } ) ;
183
+ } ) ;
0 commit comments