From: Eduardo San Martin Morote Date: Tue, 7 Apr 2020 09:41:50 +0000 (+0200) Subject: refactor: remove vue-loader usage from e2e tests X-Git-Tag: v4.0.0-alpha.5~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e9c6a30217e0863fb6ab66aae56dfea85220226;p=thirdparty%2Fvuejs%2Frouter.git refactor: remove vue-loader usage from e2e tests --- diff --git a/e2e/navigation-guards/GuardedWithLeave.vue b/e2e/navigation-guards/GuardedWithLeave.vue deleted file mode 100644 index 0cf10074..00000000 --- a/e2e/navigation-guards/GuardedWithLeave.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - diff --git a/e2e/navigation-guards/index.ts b/e2e/navigation-guards/index.ts index 64b08bc2..6fca240e 100644 --- a/e2e/navigation-guards/index.ts +++ b/e2e/navigation-guards/index.ts @@ -1,22 +1,35 @@ -import { createRouter, createWebHistory, useRoute } from '../../src' +import { createRouter, createWebHistory, onBeforeRouteLeave } from '../../src' import { RouteComponent } from '../../src/types' -import { createApp } from 'vue' -import GuardedWithLeave from './GuardedWithLeave' - -// const component: RouteComponent = { -// template: `
A component
`, -// } +import { createApp, ref } from 'vue' const Home: RouteComponent = { template: `
Home
`, } -// const Document: RouteComponent = { -// template: `
Document: {{ route.params.id }}
`, -// setup() { -// return { route: useRoute() } -// }, -// } +const GuardedWithLeave: RouteComponent = { + name: 'GuardedWithLeave', + + template: ` +
+

try to leave

+

So far, you tried {{ tries }} times

+
+ `, + + setup() { + console.log('setup in cant leave') + const tries = ref(0) + + onBeforeRouteLeave(function(to, from, next) { + if (window.confirm()) next() + else { + tries.value++ + next(false) + } + }) + return { tries } + }, +} const router = createRouter({ history: createWebHistory('/' + __dirname), @@ -26,12 +39,7 @@ const router = createRouter({ ], }) -const app = createApp({ - setup() { - const route = useRoute() - return { route } - }, -}) +const app = createApp({}) app.use(router) window.vm = app.mount('#app') diff --git a/e2e/webpack.config.js b/e2e/webpack.config.js index 60a9441e..38dccf83 100644 --- a/e2e/webpack.config.js +++ b/e2e/webpack.config.js @@ -3,7 +3,6 @@ const fs = require('fs') const { resolve, join } = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const webpack = require('webpack') -const { VueLoaderPlugin } = require('vue-loader') /** @type {string[]} */ let examples = [] @@ -59,10 +58,6 @@ const config = (env = {}) => ({ test: /\.ts$/, use: 'ts-loader', }, - { - test: /\.vue$/, - use: 'vue-loader', - }, { test: /\.css$/, use: ['style-loader', 'css-loader'], @@ -78,7 +73,6 @@ const config = (env = {}) => ({ extensions: ['.ts', '.tsx', '.js', '.vue'], }, plugins: [ - new VueLoaderPlugin(), new webpack.DefinePlugin({ __DEV__: JSON.stringify(process.env.NODE_ENV !== 'production'), __BROWSER__: `typeof window !== 'undefined'`,