mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 10:41:13 +08:00
chore(): sync with main
This commit is contained in:
@ -42,6 +42,7 @@ export {
|
||||
mdTransitionAnimation,
|
||||
setupConfig,
|
||||
IonicSwiper,
|
||||
IonicSlides,
|
||||
getPlatforms,
|
||||
isPlatform,
|
||||
menuController,
|
||||
|
@ -15,4 +15,4 @@ export default defineComponent({
|
||||
IonRouterOutlet
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
@ -8,7 +8,8 @@ import {
|
||||
IonTabs,
|
||||
IonTabBar,
|
||||
IonTabButton,
|
||||
IonLabel
|
||||
IonLabel,
|
||||
useIonRouter
|
||||
} from '@ionic/vue';
|
||||
import { onBeforeRouteLeave } from 'vue-router';
|
||||
import { waitForRouter } from './utils';
|
||||
@ -548,4 +549,117 @@ describe('Routing', () => {
|
||||
expect(wrapper.findComponent(Page2).exists()).toBe(false);
|
||||
expect(wrapper.findComponent(Page3).exists()).toBe(false);
|
||||
});
|
||||
|
||||
// Verifies fix for https://github.com/ionic-team/ionic-framework/issues/24109
|
||||
it('canGoBack() should return the correct value', async () => {
|
||||
const Page = {
|
||||
components: { IonPage },
|
||||
template: `<ion-page></ion-page>`
|
||||
}
|
||||
const Page2 = {
|
||||
components: { IonPage },
|
||||
template: `<ion-page></ion-page>`
|
||||
}
|
||||
const AppWithInject = {
|
||||
components: { IonApp, IonRouterOutlet },
|
||||
template: '<ion-app><ion-router-outlet /></ion-app>',
|
||||
setup() {
|
||||
const ionRouter = useIonRouter();
|
||||
return { ionRouter }
|
||||
}
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes: [
|
||||
{ path: '/', component: Page }
|
||||
{ path: '/page2', component: Page2 }
|
||||
]
|
||||
});
|
||||
|
||||
router.push('/');
|
||||
await router.isReady();
|
||||
const wrapper = mount(AppWithInject, {
|
||||
global: {
|
||||
plugins: [router, IonicVue]
|
||||
}
|
||||
});
|
||||
|
||||
const ionRouter = wrapper.vm.ionRouter;
|
||||
expect(ionRouter.canGoBack()).toEqual(false);
|
||||
|
||||
router.push('/page2');
|
||||
await waitForRouter();
|
||||
|
||||
expect(ionRouter.canGoBack()).toEqual(true);
|
||||
|
||||
router.back();
|
||||
await waitForRouter();
|
||||
|
||||
expect(ionRouter.canGoBack()).toEqual(false);
|
||||
});
|
||||
|
||||
// Verifies fix for https://github.com/ionic-team/ionic-framework/issues/24109
|
||||
it('canGoBack() should return the correct value when using router.go', async () => {
|
||||
const Page = {
|
||||
components: { IonPage },
|
||||
template: `<ion-page></ion-page>`
|
||||
}
|
||||
const Page2 = {
|
||||
components: { IonPage },
|
||||
template: `<ion-page></ion-page>`
|
||||
}
|
||||
const Page3 = {
|
||||
components: { IonPage },
|
||||
template: `<ion-page></ion-page>`
|
||||
}
|
||||
const AppWithInject = {
|
||||
components: { IonApp, IonRouterOutlet },
|
||||
template: '<ion-app><ion-router-outlet /></ion-app>',
|
||||
setup() {
|
||||
const ionRouter = useIonRouter();
|
||||
return { ionRouter }
|
||||
}
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes: [
|
||||
{ path: '/', component: Page }
|
||||
{ path: '/page2', component: Page2 },
|
||||
{ path: '/page3', component: Page3 },
|
||||
]
|
||||
});
|
||||
|
||||
router.push('/');
|
||||
await router.isReady();
|
||||
const wrapper = mount(AppWithInject, {
|
||||
global: {
|
||||
plugins: [router, IonicVue]
|
||||
}
|
||||
});
|
||||
|
||||
const ionRouter = wrapper.vm.ionRouter;
|
||||
expect(ionRouter.canGoBack()).toEqual(false);
|
||||
|
||||
router.push('/page2');
|
||||
await waitForRouter();
|
||||
|
||||
expect(ionRouter.canGoBack()).toEqual(true);
|
||||
|
||||
router.push('/page3');
|
||||
await waitForRouter();
|
||||
|
||||
expect(ionRouter.canGoBack()).toEqual(true);
|
||||
|
||||
router.go(-2);
|
||||
await waitForRouter();
|
||||
|
||||
expect(ionRouter.canGoBack()).toEqual(false);
|
||||
|
||||
router.go(2);
|
||||
await waitForRouter();
|
||||
|
||||
expect(ionRouter.canGoBack()).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user