]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: fix e2e paths
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 19 Mar 2020 22:26:54 +0000 (23:26 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 19 Mar 2020 22:26:54 +0000 (23:26 +0100)
e2e/encoding/index.html
e2e/hash/index.html
e2e/hash/index.ts
e2e/runner.js
package.json

index 9c304ecd0984912735703c5cf3ce48558c290701..88fa6a68c3166f64b28ce921df4dd628e795abd5 100644 (file)
@@ -9,6 +9,9 @@
     <script src="https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015"></script>
   </head>
   <body>
+    <a href="/">&lt;&lt; Back to Homepage</a>
+    <hr />
+
     <div id="app">
       <section class="info">
         Name:
         </li>
         <li>
           <a href="/encoding/documents/%E2%82%AC"
-            >/n/%E2%82%AC (force reload)</a
+            >/documents/%E2%82%AC (force reload)</a
           >
         </li>
         <li>
           <a href="/encoding/documents/€"
-            >/n/€ (force reload. not valid but should not crash the router)</a
+            >/documents/€ (force reload. not valid but should not crash the
+            router)</a
           >
         </li>
       </ul>
index 8c60324b75d8d8ad5a4544b5ff762cbf7abdc5af..8acb5abfc3662e839b3168dba63c28e33aa5c973 100644 (file)
@@ -9,35 +9,38 @@
     <script src="https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015"></script>
   </head>
   <body>
+    <a href="/">&lt;&lt; Back to Homepage</a>
+    <hr />
+
     <div id="app">
       <section class="info">
         Name:
-        <pre id="name">{{ $route.name }}</pre>
+        <pre id="name">{{ route.name }}</pre>
       </section>
 
       <section class="info">
         Params:
-        <pre id="params">{{ $route.params }}</pre>
+        <pre id="params">{{ route.params }}</pre>
       </section>
 
       <section class="info">
         Query:
-        <pre id="query">{{ $route.query }}</pre>
+        <pre id="query">{{ route.query }}</pre>
       </section>
 
       <section class="info">
         Hash:
-        <pre id="hash">{{ $route.hash }}</pre>
+        <pre id="hash">{{ route.hash }}</pre>
       </section>
 
       <section class="info">
         FullPath:
-        <pre id="fullPath">{{ $route.fullPath }}</pre>
+        <pre id="fullPath">{{ route.fullPath }}</pre>
       </section>
 
       <section class="info">
         path:
-        <pre id="path">{{ $route.path }}</pre>
+        <pre id="path">{{ route.path }}</pre>
       </section>
 
       <hr />
           >
         </li>
         <li>
-          <a href="/encoding/n/%E2%82%AC">/n/%E2%82%AC (force reload)</a>
+          <a href="/hash/#/documents/%E2%82%AC"
+            >/documents/%E2%82%AC (force reload)</a
+          >
         </li>
         <li>
-          <a href="/encoding/n/€">/n/€ (force reload): not valid tho</a>
+          <a href="/hash/#/documents/€"
+            >/documents/€ (force reload): not valid tho</a
+          >
         </li>
       </ul>
 
index a174b191c2e22d66ff9698d37f9febd4bce2cf1f..06b13ca42b9d482e49f87192907c7e407eeda250 100644 (file)
@@ -1,4 +1,4 @@
-import { createRouter, createWebHistory } from '../../src'
+import { createRouter, useRoute, createWebHashHistory } from '../../src'
 import { RouteComponent } from '../../src/types'
 import { createApp } from 'vue'
 
@@ -11,11 +11,15 @@ const Home: RouteComponent = {
 }
 
 const Document: RouteComponent = {
-  template: `<div>Document: {{ $route.params.id }}</div>`,
+  setup() {
+    const route = useRoute()
+    return { route }
+  },
+  template: `<div>Document: {{ route.params.id }}</div>`,
 }
 
 const router = createRouter({
-  history: createWebHistory('/' + __dirname),
+  history: createWebHashHistory('/' + __dirname),
   routes: [
     { path: '/', component: Home, name: 'home' },
     { path: '/documents/:id', name: 'docs', component: Document },
@@ -23,7 +27,12 @@ const router = createRouter({
   ],
 })
 
-const app = createApp({})
+const app = createApp({
+  setup() {
+    const route = useRoute()
+    return { route }
+  },
+})
 app.use(router)
 
 window.vm = app.mount('#app')
index c8de873c2d50f1f639631b6f9b255dbfd9b954db..c9465735185855e2b8e48d20edb9c974e2a8b67e 100644 (file)
@@ -26,7 +26,7 @@ const Nightwatch = require('nightwatch')
 const args = process.argv.slice(2)
 
 // if we are running yarn dev locally, we can pass --dev to avoid launching another server instance
-const server = args.indexOf('--dev') > -1 ? null : require('../examples/server')
+const server = args.indexOf('--dev') > -1 ? null : require('./server')
 
 // allow running browserstack local
 const isLocal = args.indexOf('--local') > -1
index 4450efe86521451e43f403a70a3e82a377617504..d28ed137da2b7b67d4ad1faa82e843d7155bdee7 100644 (file)
@@ -21,7 +21,7 @@
     "release": "bash scripts/release.sh",
     "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2",
     "build:playground": "webpack --env.prod",
-    "dev:examples": "webpack-dev-server --mode=development --config examples/webpack.config.js",
+    "dev:e2e": "webpack-dev-server --mode=development --config e2e/webpack.config.js",
     "lint": "prettier -c --parser typescript \"{src,__tests__,e2e}/**/*.[jt]s?(x)\"",
     "lint:fix": "yarn run lint --write",
     "test:types": "tsc --build tsconfig.json",