Skip to content

Commit bf8a29b

Browse files
wip(tests): minor factorization
1 parent 5f6c812 commit bf8a29b

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

tests/basic.test.js

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,8 @@ const { defaultFilesVue2, defaultFiles, createPage } = require('./testsTools.js'
435435
component.bazComponentProperty = 'baz';
436436
}
437437
}
438-
` +
439-
(vueVersion === 2 ? `createApp(options).then(app => mountApp(app))` : `mountApp(createApp(options))`)
440-
+ `;
438+
439+
createApp(options).then(app => mountApp(app));
441440
}
442441
`
443442
}
@@ -484,29 +483,17 @@ const { defaultFilesVue2, defaultFiles, createPage } = require('./testsTools.js'
484483
}
485484
});
486485
487-
` +
488-
489-
(vueVersion === 2 ? `
490-
createApp(options).then((app) => {
491-
mountApp(app, 'elt1')
492-
493-
options.moduleCache = {
494-
vue: Vue
495-
};
496-
497-
createApp(options).then((app2) => {
498-
mountApp(app2, 'elt2');
499-
});
500-
})` : `
501-
mountApp(createApp(options), 'elt1');
502-
503-
options.moduleCache = {
504-
vue: Vue
505-
};
506-
507-
mountApp(createApp(options), 'elt2');`)
508-
+`
486+
createApp(options).then((app) => {
487+
mountApp(app, 'elt1')
488+
489+
options.moduleCache = {
490+
vue: Vue
491+
};
509492
493+
createApp(options).then((app2) => {
494+
mountApp(app2, 'elt2');
495+
});
496+
})
510497
}
511498
`
512499
}

tests/testsTools.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const defaultFiles = {
152152
export default () => {};
153153
`,
154154
'/boot.js': `
155-
export default ({ options, createApp, mountApp }) => mountApp( createApp(options) );
155+
export default ({ options, createApp, mountApp }) => createApp(options).then(app => mountApp(app));
156156
`,
157157

158158
'/index.html': `
@@ -171,7 +171,7 @@ const defaultFiles = {
171171
172172
function createApp(options) {
173173
174-
return Vue.createApp(Vue.defineAsyncComponent( () => loadModule('./component.vue', options) ));
174+
return loadModule('./component.vue', options).then((component) => Vue.createApp(component));
175175
}
176176
177177
function mountApp(app, eltId = 'app') {
@@ -202,12 +202,8 @@ const defaultFilesVue2 = {
202202
'/vue2-sfc-loader.js': Fs.readFileSync(Path.join(__dirname, '../dist/vue2-sfc-loader.js'), { encoding: 'utf-8' }),
203203
'/vue': Fs.readFileSync(Path.join(__dirname, '../node_modules/vue2/dist/vue.runtime.js'), { encoding: 'utf-8' }),
204204
'/options.js': defaultFiles['/options.js'],
205-
'/optionsOverride.js': `
206-
export default () => {};
207-
`,
208-
'/boot.js': `
209-
export default ({ options, createApp, mountApp }) => createApp(options).then(app => mountApp(app));
210-
`,
205+
'/optionsOverride.js': defaultFiles['/optionsOverride.js'],
206+
'/boot.js': defaultFiles['/boot.js'],
211207
'/index.html': `
212208
<!DOCTYPE html>
213209
<html><body>

0 commit comments

Comments
 (0)