mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
test(vue): update vue test app dependencies (#24955)
This commit is contained in:
@ -9,13 +9,15 @@ module.exports = {
|
|||||||
'@vue/typescript/recommended'
|
'@vue/typescript/recommended'
|
||||||
],
|
],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2020
|
ecmaVersion: 2020,
|
||||||
|
parser: '@typescript-eslint/parser'
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
'vue/no-deprecated-slot-attribute': 'off',
|
'vue/no-deprecated-slot-attribute': 'off',
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'vue/multi-word-component-names': 'off'
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
preset: "@vue/cli-plugin-unit-jest/presets/typescript-and-babel",
|
preset: "@vue/cli-plugin-unit-jest/presets/typescript-and-babel",
|
||||||
transform: {
|
transform: {
|
||||||
"^.+\\.vue$": "vue-jest"
|
"^.+\\.vue$": "@vue/vue3-jest"
|
||||||
},
|
},
|
||||||
transformIgnorePatterns: ['/node_modules/(?!ionicons|@stencil/core|@ionic/core|@ionic/vue|@ionic/vue-router)'],
|
transformIgnorePatterns: ['/node_modules/(?!ionicons|@stencil/core|@ionic/core|@ionic/vue|@ionic/vue-router)'],
|
||||||
globals: {
|
globals: {
|
||||||
|
40856
packages/vue/test-app/package-lock.json
generated
40856
packages/vue/test-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -13,30 +13,32 @@
|
|||||||
"sync": "sh ./scripts/sync.sh"
|
"sync": "sh ./scripts/sync.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ionic/vue": "5.6.3",
|
"@ionic/vue": "^6.0.12",
|
||||||
"@ionic/vue-router": "5.6.3",
|
"@ionic/vue-router": "^6.0.12",
|
||||||
"vue": "^3.2.22",
|
"vue": "^3.2.31",
|
||||||
"vue-router": "^4.0.12"
|
"vue-router": "^4.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.19",
|
"@types/jest": "^24.0.19",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||||
"@typescript-eslint/parser": "^2.33.0",
|
"@typescript-eslint/parser": "^5.4.0",
|
||||||
"@vue/cli-plugin-babel": "~4.5.15",
|
"@vue/cli-plugin-babel": "~5.0.3",
|
||||||
"@vue/cli-plugin-e2e-cypress": "^5.0.0-alpha.7",
|
"@vue/cli-plugin-e2e-cypress": "~5.0.3",
|
||||||
"@vue/cli-plugin-eslint": "~4.5.15",
|
"@vue/cli-plugin-eslint": "~5.0.3",
|
||||||
"@vue/cli-plugin-router": "~4.5.15",
|
"@vue/cli-plugin-router": "~5.0.3",
|
||||||
"@vue/cli-plugin-typescript": "~4.5.15",
|
"@vue/cli-plugin-typescript": "~5.0.3",
|
||||||
"@vue/cli-plugin-unit-jest": "~4.5.15",
|
"@vue/cli-plugin-unit-jest": "~5.0.3",
|
||||||
"@vue/cli-service": "~4.5.15",
|
"@vue/cli-service": "~5.0.3",
|
||||||
"@vue/compiler-sfc": "^3.0.0-0",
|
"@vue/eslint-config-typescript": "^9.1.0",
|
||||||
"@vue/eslint-config-typescript": "^5.0.2",
|
|
||||||
"@vue/test-utils": "^2.0.0-rc.18",
|
"@vue/test-utils": "^2.0.0-rc.18",
|
||||||
|
"@vue/vue3-jest": "^27.0.0-alpha.4",
|
||||||
"concurrently": "^6.0.0",
|
"concurrently": "^6.0.0",
|
||||||
"eslint": "^6.7.2",
|
"cypress": "^8.3.0",
|
||||||
"eslint-plugin-vue": "^7.0.0-0",
|
"eslint": "^7.32.0",
|
||||||
"typescript": "~4.1.5",
|
"eslint-plugin-vue": "^8.0.3",
|
||||||
"vue-jest": "^5.0.0-0",
|
"jest": "^27.1.0",
|
||||||
|
"ts-jest": "^27.0.4",
|
||||||
|
"typescript": "~4.5.5",
|
||||||
"wait-on": "^5.3.0"
|
"wait-on": "^5.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import { IonApp, IonRouterOutlet, useIonRouter } from '@ionic/vue';
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'App',
|
|
||||||
components: {
|
components: {
|
||||||
IonApp,
|
IonApp,
|
||||||
IonRouterOutlet
|
IonRouterOutlet
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ExploreContainer',
|
|
||||||
props: {
|
props: {
|
||||||
name: String
|
name: String
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import {
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ModalContent',
|
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'PopoverContent',
|
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
},
|
},
|
||||||
|
@ -23,17 +23,14 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/overlays',
|
path: '/overlays',
|
||||||
name: 'Overlays',
|
|
||||||
component: () => import('@/views/Overlays.vue')
|
component: () => import('@/views/Overlays.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/inputs',
|
path: '/inputs',
|
||||||
name: 'Inputs',
|
|
||||||
component: () => import('@/views/Inputs.vue')
|
component: () => import('@/views/Inputs.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/slides',
|
path: '/slides',
|
||||||
name: 'Slides',
|
|
||||||
component: () => import('@/views/Slides.vue')
|
component: () => import('@/views/Slides.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -63,7 +60,6 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/nested',
|
path: '/nested',
|
||||||
name: 'RouterOutlet',
|
|
||||||
component: () => import('@/views/RouterOutlet.vue'),
|
component: () => import('@/views/RouterOutlet.vue'),
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
import { IonButtons, IonContent, IonHeader, IonMenuButton, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
|
import { IonButtons, IonContent, IonHeader, IonMenuButton, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Folder',
|
|
||||||
components: {
|
components: {
|
||||||
IonButtons,
|
IonButtons,
|
||||||
IonContent,
|
IonContent,
|
||||||
|
@ -64,7 +64,6 @@ import { IonButtons, IonBackButton, IonContent, IonHeader, IonItem, IonLabel, Io
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Home',
|
|
||||||
components: {
|
components: {
|
||||||
IonButtons,
|
IonButtons,
|
||||||
IonBackButton,
|
IonBackButton,
|
||||||
|
@ -132,7 +132,6 @@ import {
|
|||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent, ref } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Home',
|
|
||||||
components: {
|
components: {
|
||||||
IonBackButton,
|
IonBackButton,
|
||||||
IonButton,
|
IonButton,
|
||||||
|
@ -38,7 +38,6 @@ import {
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'NestedChild',
|
|
||||||
components: {
|
components: {
|
||||||
IonBackButton,
|
IonBackButton,
|
||||||
IonButton,
|
IonButton,
|
||||||
|
@ -32,7 +32,6 @@ import {
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'NestedChildTwo',
|
|
||||||
components: {
|
components: {
|
||||||
IonBackButton,
|
IonBackButton,
|
||||||
IonButtons,
|
IonButtons,
|
||||||
|
@ -164,7 +164,6 @@ import ModalContent from '@/components/ModalContent.vue';
|
|||||||
import PopoverContent from '@/components/PopoverContent.vue';
|
import PopoverContent from '@/components/PopoverContent.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Overlays',
|
|
||||||
components: {
|
components: {
|
||||||
ModalContent,
|
ModalContent,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
|
@ -30,7 +30,6 @@ import {
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'RouterOutlet',
|
|
||||||
components: {
|
components: {
|
||||||
IonHeader,
|
IonHeader,
|
||||||
IonButtons,
|
IonButtons,
|
||||||
|
@ -50,7 +50,6 @@ import {
|
|||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent, ref } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Home',
|
|
||||||
components: {
|
components: {
|
||||||
IonBackButton,
|
IonBackButton,
|
||||||
IonButton,
|
IonButton,
|
||||||
|
@ -44,7 +44,6 @@ import { IonButtons, IonBackButton, IonPage, IonHeader, IonItem, IonLabel, IonTo
|
|||||||
import ExploreContainer from '@/components/ExploreContainer.vue';
|
import ExploreContainer from '@/components/ExploreContainer.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Tab1',
|
|
||||||
components: { IonButtons, IonBackButton, ExploreContainer, IonHeader, IonItem, IonLabel, IonToolbar, IonTitle, IonContent, IonPage }
|
components: { IonButtons, IonBackButton, ExploreContainer, IonHeader, IonItem, IonLabel, IonToolbar, IonTitle, IonContent, IonPage }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -22,7 +22,6 @@ import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/vue
|
|||||||
import ExploreContainer from '@/components/ExploreContainer.vue';
|
import ExploreContainer from '@/components/ExploreContainer.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Tab3',
|
|
||||||
components: { ExploreContainer, IonHeader, IonToolbar, IonTitle, IonContent, IonPage }
|
components: { ExploreContainer, IonHeader, IonToolbar, IonTitle, IonContent, IonPage }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -28,7 +28,6 @@ import { useRouter } from 'vue-router';
|
|||||||
import { ref, defineComponent } from 'vue';
|
import { ref, defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Tabs',
|
|
||||||
components: { IonButton, IonContent, IonLabel, IonTabs, IonTabBar, IonTabButton, IonIcon, IonPage, IonRouterOutlet },
|
components: { IonButton, IonContent, IonLabel, IonTabs, IonTabBar, IonTabButton, IonIcon, IonPage, IonRouterOutlet },
|
||||||
setup() {
|
setup() {
|
||||||
const tabs = ref([
|
const tabs = ref([
|
||||||
|
@ -29,7 +29,6 @@ import { IonTabBar, IonTabButton, IonTabs, IonContent, IonLabel, IonIcon, IonPag
|
|||||||
import { ellipse, square, triangle } from 'ionicons/icons';
|
import { ellipse, square, triangle } from 'ionicons/icons';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Tabs',
|
|
||||||
components: { IonContent, IonLabel, IonTabs, IonTabBar, IonTabButton, IonIcon, IonPage, IonRouterOutlet },
|
components: { IonContent, IonLabel, IonTabs, IonTabBar, IonTabButton, IonIcon, IonPage, IonRouterOutlet },
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
|
@ -32,7 +32,6 @@ import {
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Home',
|
|
||||||
components: {
|
components: {
|
||||||
IonBackButton,
|
IonBackButton,
|
||||||
IonButtons,
|
IonButtons,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { createRouter, createWebHistory } from '@ionic/vue-router';
|
import { createRouter, createWebHistory } from '@ionic/vue-router';
|
||||||
import { IonicVue, IonApp, IonRouterOutlet, IonPage, useIonRouter, createAnimation } from '@ionic/vue';
|
import { IonicVue, IonApp, IonRouterOutlet, IonPage, useIonRouter, createAnimation } from '@ionic/vue';
|
||||||
import { waitForRouter } from './utils';
|
import { mockAnimation, waitForRouter } from './utils';
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
components: { IonApp, IonRouterOutlet },
|
components: { IonApp, IonRouterOutlet },
|
||||||
@ -59,7 +59,7 @@ describe('useIonRouter', () => {
|
|||||||
|
|
||||||
const cmp = wrapper.findComponent(Page2);
|
const cmp = wrapper.findComponent(Page2);
|
||||||
const vm = cmp.vm as any;
|
const vm = cmp.vm as any;
|
||||||
const animFn = jest.fn();
|
const animFn = mockAnimation();
|
||||||
|
|
||||||
vm.ionRouter.back(animFn);
|
vm.ionRouter.back(animFn);
|
||||||
await waitForRouter();
|
await waitForRouter();
|
||||||
@ -104,7 +104,7 @@ describe('useIonRouter', () => {
|
|||||||
|
|
||||||
const cmp = wrapper.findComponent(Page2);
|
const cmp = wrapper.findComponent(Page2);
|
||||||
const vm = cmp.vm as any;
|
const vm = cmp.vm as any;
|
||||||
const animFn = jest.fn();
|
const animFn = mockAnimation();
|
||||||
|
|
||||||
vm.ionRouter.back();
|
vm.ionRouter.back();
|
||||||
await waitForRouter();
|
await waitForRouter();
|
||||||
@ -153,7 +153,7 @@ describe('useIonRouter', () => {
|
|||||||
|
|
||||||
const cmp = wrapper.findComponent(Page1);
|
const cmp = wrapper.findComponent(Page1);
|
||||||
const vm = cmp.vm as any;
|
const vm = cmp.vm as any;
|
||||||
const animFn = jest.fn();
|
const animFn = mockAnimation();
|
||||||
|
|
||||||
vm.ionRouter.push('/page2', animFn);
|
vm.ionRouter.push('/page2', animFn);
|
||||||
await waitForRouter();
|
await waitForRouter();
|
||||||
@ -197,13 +197,13 @@ describe('useIonRouter', () => {
|
|||||||
|
|
||||||
const cmp = wrapper.findComponent(Page1);
|
const cmp = wrapper.findComponent(Page1);
|
||||||
const vm = cmp.vm as any;
|
const vm = cmp.vm as any;
|
||||||
const animFn = jest.fn();
|
const animFn = mockAnimation();
|
||||||
|
|
||||||
vm.ionRouter.replace('/page2', animFn);
|
vm.ionRouter.replace('/page2', animFn);
|
||||||
await waitForRouter();
|
await waitForRouter();
|
||||||
|
|
||||||
expect(router.currentRoute.value.path).toEqual('/page2');
|
expect(router.currentRoute.value.path).toEqual('/page2');
|
||||||
expect(animFn).toHaveBeenCalled();
|
expect(animFn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(vm.ionRouter.canGoBack()).toEqual(false);
|
expect(vm.ionRouter.canGoBack()).toEqual(false);
|
||||||
})
|
})
|
||||||
@ -243,7 +243,7 @@ describe('useIonRouter', () => {
|
|||||||
|
|
||||||
const cmp = wrapper.findComponent(Page1);
|
const cmp = wrapper.findComponent(Page1);
|
||||||
const vm = cmp.vm as any;
|
const vm = cmp.vm as any;
|
||||||
const animFn = jest.fn();
|
const animFn = mockAnimation();
|
||||||
|
|
||||||
vm.ionRouter.navigate('/page2', 'forward', 'push', animFn);
|
vm.ionRouter.navigate('/page2', 'forward', 'push', animFn);
|
||||||
await waitForRouter();
|
await waitForRouter();
|
||||||
|
@ -14,6 +14,7 @@ describe('IonPage', () => {
|
|||||||
it('should add ion-page class', async () => {
|
it('should add ion-page class', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
template: '<ion-page></ion-page>',
|
template: '<ion-page></ion-page>',
|
||||||
|
name: 'Page1',
|
||||||
components: { IonPage }
|
components: { IonPage }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ describe('IonPage', () => {
|
|||||||
it('should preserve custom classes', async () => {
|
it('should preserve custom classes', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
template: '<ion-page class="custom-class"></ion-page>',
|
template: '<ion-page class="custom-class"></ion-page>',
|
||||||
|
name: 'Page1',
|
||||||
components: { IonPage }
|
components: { IonPage }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ describe('Routing', () => {
|
|||||||
it('should pass no props', async () => {
|
it('should pass no props', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
}
|
}
|
||||||
@ -60,6 +61,7 @@ describe('Routing', () => {
|
|||||||
it('should pass route props as an object', async () => {
|
it('should pass route props as an object', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
}
|
}
|
||||||
@ -87,6 +89,7 @@ describe('Routing', () => {
|
|||||||
it('should pass route props as a function', async () => {
|
it('should pass route props as a function', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
}
|
}
|
||||||
@ -131,6 +134,7 @@ describe('Routing', () => {
|
|||||||
it('should pass route params as props', async () => {
|
it('should pass route params as props', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
}
|
}
|
||||||
@ -159,13 +163,15 @@ describe('Routing', () => {
|
|||||||
const leaveHook = jest.fn();
|
const leaveHook = jest.fn();
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
setup() {
|
setup() {
|
||||||
onBeforeRouteLeave(leaveHook);
|
onBeforeRouteLeave(leaveHook);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Page2 = {
|
const Page2 = {
|
||||||
...BasePage
|
...BasePage,
|
||||||
|
name: 'Page2',
|
||||||
};
|
};
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
@ -195,6 +201,7 @@ describe('Routing', () => {
|
|||||||
it('should show correct view when replacing', async () => {
|
it('should show correct view when replacing', async () => {
|
||||||
const Tabs = {
|
const Tabs = {
|
||||||
components: { IonPage, IonTabs, IonTabBar, IonTabButton, IonLabel, IonRouterOutlet },
|
components: { IonPage, IonTabs, IonTabBar, IonTabButton, IonLabel, IonRouterOutlet },
|
||||||
|
name: 'Tabs',
|
||||||
template: `
|
template: `
|
||||||
<ion-page>
|
<ion-page>
|
||||||
<ion-tabs>
|
<ion-tabs>
|
||||||
@ -213,14 +220,17 @@ describe('Routing', () => {
|
|||||||
}
|
}
|
||||||
const Tab1 = {
|
const Tab1 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Tab1',
|
||||||
template: `<ion-page>Tab 1</ion-page>`
|
template: `<ion-page>Tab 1</ion-page>`
|
||||||
}
|
}
|
||||||
const Tab2 = {
|
const Tab2 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Tab2',
|
||||||
template: `<ion-page>Tab 2</ion-page>`
|
template: `<ion-page>Tab 2</ion-page>`
|
||||||
}
|
}
|
||||||
const Parent = {
|
const Parent = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Parent',
|
||||||
template: `<ion-page>Parent Page</ion-page>`
|
template: `<ion-page>Parent Page</ion-page>`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,13 +283,15 @@ describe('Routing', () => {
|
|||||||
it('should show the latest props passed to a route', async () => {
|
it('should show the latest props passed to a route', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Home = {
|
const Home = {
|
||||||
...BasePage
|
...BasePage,
|
||||||
|
name: 'Home',
|
||||||
}
|
}
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
@ -320,13 +332,15 @@ describe('Routing', () => {
|
|||||||
it('should call the props function again when params change', async () => {
|
it('should call the props function again when params change', async () => {
|
||||||
const Page1 = {
|
const Page1 = {
|
||||||
...BasePage,
|
...BasePage,
|
||||||
|
name: 'Page1',
|
||||||
props: {
|
props: {
|
||||||
title: { type: String, default: 'Default Title' }
|
title: { type: String, default: 'Default Title' }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Home = {
|
const Home = {
|
||||||
...BasePage
|
...BasePage,
|
||||||
|
name: 'Home',
|
||||||
}
|
}
|
||||||
|
|
||||||
const propsFn = jest.fn((route) => {
|
const propsFn = jest.fn((route) => {
|
||||||
@ -372,6 +386,7 @@ describe('Routing', () => {
|
|||||||
// Verifies fix for https://github.com/ionic-team/ionic-framework/pull/23189
|
// Verifies fix for https://github.com/ionic-team/ionic-framework/pull/23189
|
||||||
it('should update props on a parameterized url', async () => {
|
it('should update props on a parameterized url', async () => {
|
||||||
const Page = {
|
const Page = {
|
||||||
|
name: 'Page',
|
||||||
props: {
|
props: {
|
||||||
id: { type: String, default: 'Default ID' }
|
id: { type: String, default: 'Default ID' }
|
||||||
},
|
},
|
||||||
@ -416,11 +431,13 @@ describe('Routing', () => {
|
|||||||
beforeRouteLeave() {
|
beforeRouteLeave() {
|
||||||
beforeRouteLeaveSpy();
|
beforeRouteLeaveSpy();
|
||||||
},
|
},
|
||||||
|
name: 'Page',
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page2 = {
|
const Page2 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page2',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,14 +475,17 @@ describe('Routing', () => {
|
|||||||
it('canGoBack() should return the correct value', async () => {
|
it('canGoBack() should return the correct value', async () => {
|
||||||
const Page = {
|
const Page = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page2 = {
|
const Page2 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page2',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const AppWithInject = {
|
const AppWithInject = {
|
||||||
components: { IonApp, IonRouterOutlet },
|
components: { IonApp, IonRouterOutlet },
|
||||||
|
name: 'AppWithInject',
|
||||||
template: '<ion-app><ion-router-outlet /></ion-app>',
|
template: '<ion-app><ion-router-outlet /></ion-app>',
|
||||||
setup() {
|
setup() {
|
||||||
const ionRouter = useIonRouter();
|
const ionRouter = useIonRouter();
|
||||||
@ -507,18 +527,22 @@ describe('Routing', () => {
|
|||||||
it('canGoBack() should return the correct value when using router.go', async () => {
|
it('canGoBack() should return the correct value when using router.go', async () => {
|
||||||
const Page = {
|
const Page = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page2 = {
|
const Page2 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page2',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page3 = {
|
const Page3 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page3',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const AppWithInject = {
|
const AppWithInject = {
|
||||||
components: { IonApp, IonRouterOutlet },
|
components: { IonApp, IonRouterOutlet },
|
||||||
|
name: 'AppWithInject',
|
||||||
template: '<ion-app><ion-router-outlet /></ion-app>',
|
template: '<ion-app><ion-router-outlet /></ion-app>',
|
||||||
setup() {
|
setup() {
|
||||||
const ionRouter = useIonRouter();
|
const ionRouter = useIonRouter();
|
||||||
@ -570,14 +594,17 @@ describe('Routing', () => {
|
|||||||
it('should not mount intermediary components when delta is 1', async () => {
|
it('should not mount intermediary components when delta is 1', async () => {
|
||||||
const Page = {
|
const Page = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page2 = {
|
const Page2 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page2',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page3 = {
|
const Page3 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page3',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,14 +648,17 @@ describe('Routing', () => {
|
|||||||
it('should unmount intermediary components when using router.go', async () => {
|
it('should unmount intermediary components when using router.go', async () => {
|
||||||
const Page = {
|
const Page = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page2 = {
|
const Page2 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page2',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
const Page3 = {
|
const Page3 = {
|
||||||
components: { IonPage },
|
components: { IonPage },
|
||||||
|
name: 'Page3',
|
||||||
template: `<ion-page></ion-page>`
|
template: `<ion-page></ion-page>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,5 +2,14 @@ import { flushPromises } from '@vue/test-utils';
|
|||||||
|
|
||||||
export const waitForRouter = async () => {
|
export const waitForRouter = async () => {
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
await new Promise((r) => setTimeout(r, 100));
|
await new Promise((r) => setTimeout(r, 500));
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mockAnimation = () => {
|
||||||
|
return jest.fn(() => {
|
||||||
|
return {
|
||||||
|
onFinish: () => {},
|
||||||
|
play: () => {}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user