Skip to content

Commit

Permalink
test: fix e2e paths
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 19, 2020
1 parent 55d125b commit a3e0be9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
8 changes: 6 additions & 2 deletions e2e/encoding/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -64,12 +67,13 @@
</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>
Expand Down
23 changes: 15 additions & 8 deletions e2e/hash/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand All @@ -63,10 +66,14 @@
>
</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>

Expand Down
17 changes: 13 additions & 4 deletions e2e/hash/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from '../../src'
import { createRouter, useRoute, createWebHashHistory } from '../../src'
import { RouteComponent } from '../../src/types'
import { createApp } from 'vue'

Expand All @@ -11,19 +11,28 @@ 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 },
{ path: encodeURI('/n/€'), name: 'euro', component },
],
})

const app = createApp({})
const app = createApp({
setup() {
const route = useRoute()
return { route }
},
})
app.use(router)

window.vm = app.mount('#app')
2 changes: 1 addition & 1 deletion e2e/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a3e0be9

Please sign in to comment.