@@ -188,6 +188,44 @@ const app_example_3_output = {
188188 "/build/src/widget/alias.jsx" : "return <h1>Hello world!</h1>;\n" ,
189189} ;
190190
191+ const unformated_example = {
192+ "./bos.config.json" : JSON . stringify ( {
193+ ...DEFAULT_CONFIG ,
194+ account : "test.near" ,
195+ format : false
196+ } ) ,
197+ "./widget/alias.tsx" : "function add(a,b){return a+b} let result=add(1,2);console.log(result);" ,
198+ } ;
199+
200+ const unformated_output = {
201+ "/build/data.json" : JSON . stringify ( {
202+ "test.near" : { }
203+ } , null , 2 ) + "\n" ,
204+ "/build/src/widget/alias.jsx" : "function add(a,b){return a+b} let result=add(1,2);console.log(result);" ,
205+ } ;
206+
207+ const formated_example = {
208+ "./bos.config.json" : JSON . stringify ( {
209+ ...DEFAULT_CONFIG ,
210+ account : "test.near" ,
211+ format : true
212+ } ) ,
213+ "./widget/alias.tsx" : "function add(a,b){return a+b} let result=add(1,2);console.log(result);" ,
214+ } ;
215+
216+ const formated_output = {
217+ "/build/data.json" : JSON . stringify ( {
218+ "test.near" : { }
219+ } , null , 2 ) + "\n" ,
220+ "/build/src/widget/alias.jsx" : `function add(a, b) {
221+ return a + b;
222+ }
223+ let result = add(1, 2);
224+ console.log(result);
225+ ` ,
226+ } ;
227+
228+
191229const unmockedFetch = global . fetch ;
192230const unmockedLog = global . log ;
193231
@@ -228,4 +266,16 @@ describe('build', () => {
228266 await buildApp ( '/app_example_3' , '/build' ) ;
229267 expect ( vol . toJSON ( '/build' ) ) . toEqual ( app_example_3_output ) ;
230268 } )
269+
270+ it ( 'should format when format enabled' , async ( ) => {
271+ vol . fromJSON ( formated_example , '/formated_example' ) ;
272+ await buildApp ( '/formated_example' , '/build' ) ;
273+ expect ( vol . toJSON ( '/build' ) ) . toEqual ( formated_output ) ;
274+ } )
275+
276+ it ( 'should not format when format disabled' , async ( ) => {
277+ vol . fromJSON ( unformated_example , '/unformated_example' ) ;
278+ await buildApp ( '/unformated_example' , '/build' ) ;
279+ expect ( vol . toJSON ( '/build' ) ) . toEqual ( unformated_output ) ;
280+ } )
231281} )
0 commit comments