-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vue): tab bar now works with slot="top" (#22461)
resolves #22456
- Loading branch information
1 parent
f5b0299
commit e17c822
Showing
4 changed files
with
151 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import { createRouter, createWebHistory } from '@ionic/vue-router'; | ||
import { IonicVue, IonApp, IonRouterOutlet, IonPage, IonTabs, IonTabBar } from '@ionic/vue'; | ||
|
||
const App = { | ||
components: { IonApp, IonRouterOutlet }, | ||
template: '<ion-app><ion-router-outlet /></ion-app>', | ||
} | ||
|
||
describe('ion-tab-bar', () => { | ||
it('should render in the top slot', async () => { | ||
const Tabs = { | ||
components: { IonPage, IonTabs, IonTabBar }, | ||
template: ` | ||
<ion-page> | ||
<ion-tabs> | ||
<ion-tab-bar slot="top"></ion-tab-bar> | ||
</ion-tabs> | ||
</ion-page> | ||
`, | ||
} | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(process.env.BASE_URL), | ||
routes: [ | ||
{ path: '/', component: Tabs } | ||
] | ||
}); | ||
|
||
router.push('/'); | ||
await router.isReady(); | ||
const wrapper = mount(App, { | ||
global: { | ||
plugins: [router, IonicVue] | ||
} | ||
}); | ||
|
||
const innerHTML = wrapper.find('ion-tabs').html(); | ||
expect(innerHTML).toContain(`<ion-tab-bar slot="top"></ion-tab-bar><div class="tabs-inner" style="position: relative; flex: 1; contain: layout size style;">`); | ||
|
||
}); | ||
|
||
it('should render in the bottom slot', async () => { | ||
const Tabs = { | ||
components: { IonPage, IonTabs, IonTabBar }, | ||
template: ` | ||
<ion-page> | ||
<ion-tabs> | ||
<ion-tab-bar slot="bottom"></ion-tab-bar> | ||
</ion-tabs> | ||
</ion-page> | ||
`, | ||
} | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(process.env.BASE_URL), | ||
routes: [ | ||
{ path: '/', component: Tabs } | ||
] | ||
}); | ||
|
||
router.push('/'); | ||
await router.isReady(); | ||
const wrapper = mount(App, { | ||
global: { | ||
plugins: [router, IonicVue] | ||
} | ||
}); | ||
|
||
const innerHTML = wrapper.find('ion-tabs').html(); | ||
expect(innerHTML).toContain(`<div class="tabs-inner" style="position: relative; flex: 1; contain: layout size style;"><ion-router-outlet tabs="true"></ion-router-outlet></div><ion-tab-bar slot="bottom"></ion-tab-bar>`); | ||
|
||
}); | ||
|
||
it('should render in the default slot', async () => { | ||
const Tabs = { | ||
components: { IonPage, IonTabs, IonTabBar }, | ||
template: ` | ||
<ion-page> | ||
<ion-tabs> | ||
<ion-tab-bar></ion-tab-bar> | ||
</ion-tabs> | ||
</ion-page> | ||
`, | ||
} | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(process.env.BASE_URL), | ||
routes: [ | ||
{ path: '/', component: Tabs } | ||
] | ||
}); | ||
|
||
router.push('/'); | ||
await router.isReady(); | ||
const wrapper = mount(App, { | ||
global: { | ||
plugins: [router, IonicVue] | ||
} | ||
}); | ||
|
||
const innerHTML = wrapper.find('ion-tabs').html(); | ||
expect(innerHTML).toContain(`<div class="tabs-inner" style="position: relative; flex: 1; contain: layout size style;"><ion-router-outlet tabs="true"></ion-router-outlet></div><ion-tab-bar></ion-tab-bar></ion-tabs>`) | ||
}); | ||
}); |