@@ -56,37 +56,32 @@ Module._load = function (request, parent) {
5656
5757const staticDeployMod = require ( join ( process . cwd ( ) , 'src' , 'static' , 'index.js' ) )
5858
59- let defaultParams = ( ) => ( {
60- bucket : 'a-bucket' ,
61- isDryRun : false ,
62- name : 'an-app' ,
63- production : false ,
64- region : 'us-west-1' ,
65- stackname : undefined ,
66- update : updater ( 'Deploy' ) ,
67- verbose : undefined ,
68- // `@static` settings
69- prefix : undefined ,
70- prune : false ,
71- } )
72- let params = defaultParams ( )
59+ let testParams = { }
7360
7461function setup ( ) {
7562 published = undefined
76- }
77- function reset ( ) {
78- params = defaultParams ( )
63+ testParams = { }
7964}
8065
8166function staticDeploy ( cwd , callback ) {
8267 inventory ( { cwd } , function ( err , result ) {
8368 if ( err ) callback ( err )
8469 else {
85- params . inventory = result
86- staticDeployMod ( params , err => {
87- reset ( )
88- callback ( err )
89- } )
70+ const params = {
71+ bucket : 'a-bucket' ,
72+ isDryRun : false ,
73+ name : 'an-app' ,
74+ production : false ,
75+ region : 'us-west-1' ,
76+ stackname : undefined ,
77+ update : updater ( 'Deploy' ) ,
78+ verbose : undefined ,
79+ // `@static` settings
80+ prefix : testParams . prefix !== undefined ? testParams . prefix : undefined ,
81+ prune : testParams . prune !== undefined ? testParams . prune : false ,
82+ inventory : result ,
83+ }
84+ staticDeployMod ( params , callback )
9085 }
9186 } )
9287}
@@ -143,10 +138,10 @@ test(`Publish static deploy if @static is defined`, async () => {
143138 cleanupTmpDir ( cwd )
144139 if ( err ) reject ( err )
145140 else {
146- assert . strictEqual ( published . Bucket , params . bucket , 'Bucket is unchanged' )
141+ assert . strictEqual ( published . Bucket , 'a- bucket' , 'Bucket is unchanged' )
147142 assert . strictEqual ( published . prefix , null , 'Prefix set to null by default' )
148143 assert . strictEqual ( published . prune , null , 'Prune set to null by default' )
149- assert . strictEqual ( published . region , params . region , 'Region is unchaged' )
144+ assert . strictEqual ( published . region , 'us-west-1' , 'Region is unchaged' )
150145 resolve ( )
151146 }
152147 } )
@@ -171,9 +166,9 @@ test(`Publish static deploy if @http is defined and public/ folder is present`,
171166
172167test ( `Respect prune param` , async ( ) => {
173168 setup ( )
169+ testParams . prune = true
174170 let arc = '@app\n an-app\n @static'
175171 let cwd = createTmpDir ( { 'app.arc' : arc , 'public' : { } } )
176- params . prune = true
177172 await new Promise ( ( resolve , reject ) => {
178173 staticDeploy ( cwd , err => {
179174 cleanupTmpDir ( cwd )
@@ -204,9 +199,9 @@ test(`Respect prune setting in project manifest`, async () => {
204199
205200test ( `Respect prefix param` , async ( ) => {
206201 setup ( )
202+ testParams . prefix = 'some-prefix'
207203 let arc = '@app\n an-app\n @static'
208204 let cwd = createTmpDir ( { 'app.arc' : arc , 'public' : { } } )
209- params . prefix = 'some-prefix'
210205 await new Promise ( ( resolve , reject ) => {
211206 staticDeploy ( cwd , err => {
212207 cleanupTmpDir ( cwd )
@@ -236,6 +231,5 @@ test(`Respect prefix setting in project manifest`, async () => {
236231} )
237232
238233test ( 'Teardown' , ( ) => {
239- reset ( )
240234 assert . ok ( true , 'Done' )
241235} )
0 commit comments