Skip to content

Commit 40c87f6

Browse files
committed
chore: tests
1 parent 51edf69 commit 40c87f6

File tree

2 files changed

+47
-44
lines changed

2 files changed

+47
-44
lines changed

packages/playground/src/App.vue

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -183,51 +183,43 @@
183183
</div>
184184
</template>
185185

186-
<script lang="ts">
186+
<script lang="ts" setup>
187187
import { defineComponent, inject, computed, ref } from 'vue'
188188
import { scrollWaiter } from './scrollWaiter'
189-
import { useLink, useRoute } from 'vue-router'
189+
import { useLink, useRoute, RouterLink } from 'vue-router'
190190
import AppLink from './AppLink.vue'
191191
192-
export default defineComponent({
193-
name: 'App',
194-
components: { AppLink },
195-
setup() {
196-
const route = useRoute()
197-
const state = inject('state')
198-
const viewName = ref('default')
192+
const route = useRoute()
193+
const state = inject('state')
194+
const viewName = ref('default')
199195
200-
useLink({ to: '/' })
201-
useLink({ to: '/documents/hello' })
202-
useLink({ to: '/children' })
196+
useLink({ to: '/' })
197+
useLink({ to: '/documents/hello' })
198+
useLink({ to: '/children' })
203199
204-
const currentLocation = computed(() => {
205-
const { matched, ...rest } = route
206-
return rest
207-
})
200+
const currentLocation = computed(() => {
201+
const { matched, ...rest } = route
202+
return rest
203+
})
208204
209-
function flushWaiter() {
210-
scrollWaiter.flush()
211-
}
212-
function setupWaiter() {
213-
scrollWaiter.add()
214-
}
205+
function flushWaiter() {
206+
scrollWaiter.flush()
207+
}
208+
function setupWaiter() {
209+
scrollWaiter.add()
210+
}
215211
216-
const nextUserLink = computed(
217-
() => '/users/' + String((Number(route.params.id) || 0) + 1)
218-
)
212+
const nextUserLink = computed(
213+
() => '/users/' + String((Number(route.params.id) || 0) + 1)
214+
)
219215
220-
return {
221-
currentLocation,
222-
nextUserLink,
223-
state,
224-
flushWaiter,
225-
setupWaiter,
226-
viewName,
227-
toggleViewName() {
228-
viewName.value = viewName.value === 'default' ? 'other' : 'default'
229-
},
230-
}
231-
},
232-
})
216+
currentLocation,
217+
nextUserLink,
218+
state,
219+
flushWaiter,
220+
setupWaiter,
221+
viewName,
222+
function toggleViewName() {
223+
viewName.value = viewName.value === 'default' ? 'other' : 'default'
224+
}
233225
</script>

packages/playground/src/main.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,22 @@ declare module 'vue-router' {
5353
}
5454
}
5555

56-
const r = useRoute()
56+
function _ok() {
57+
const r = useRoute()
5758

58-
if (r.name === '/[name]') {
59-
r.params.name.toUpperCase()
60-
// @ts-expect-error: Not existing route
61-
} else if (r.name === 'nope') {
62-
console.log('nope')
59+
if (r.name === '/[name]') {
60+
r.params.name.toUpperCase()
61+
// @ts-expect-error: Not existing route
62+
} else if (r.name === 'nope') {
63+
console.log('nope')
64+
}
65+
66+
router.push({
67+
name: '/[name]',
68+
params: { name: 'hey' },
69+
})
70+
71+
router
72+
.resolve({ name: '/[name]', params: { name: 2 } })
73+
.params.name.toUpperCase()
6374
}

0 commit comments

Comments
 (0)