-
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): preserve custom classes on IonPage (#24776)
resolves #24772 Co-authored-by: bnachtweh <bnachtweh@users.noreply.github.com>
- Loading branch information
1 parent
abc36ae
commit b401de1
Showing
2 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import { createRouter, createWebHistory } from '@ionic/vue-router'; | ||
import { IonicVue, IonApp, IonRouterOutlet, IonPage } from '@ionic/vue'; | ||
|
||
const App = { | ||
components: { IonApp, IonRouterOutlet }, | ||
template: '<ion-app><ion-router-outlet /></ion-app>', | ||
} | ||
|
||
describe('IonPage', () => { | ||
beforeAll(() => { | ||
(HTMLElement.prototype as HTMLIonRouterOutletElement).commit = jest.fn(); | ||
}); | ||
it('should add ion-page class', async () => { | ||
const Page1 = { | ||
template: '<ion-page></ion-page>', | ||
components: { IonPage } | ||
}; | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(process.env.BASE_URL), | ||
routes: [ | ||
{ path: '/', component: Page1 } | ||
] | ||
}); | ||
|
||
router.push('/'); | ||
await router.isReady(); | ||
const wrapper = mount(App, { | ||
global: { | ||
plugins: [router, IonicVue] | ||
} | ||
}); | ||
|
||
const cmp = wrapper.findComponent(Page1); | ||
expect(cmp.classes('ion-page')).toBe(true); | ||
}); | ||
it('should preserve custom classes', async () => { | ||
const Page1 = { | ||
template: '<ion-page class="custom-class"></ion-page>', | ||
components: { IonPage } | ||
}; | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(process.env.BASE_URL), | ||
routes: [ | ||
{ path: '/', component: Page1 } | ||
] | ||
}); | ||
|
||
router.push('/'); | ||
await router.isReady(); | ||
const wrapper = mount(App, { | ||
global: { | ||
plugins: [router, IonicVue] | ||
} | ||
}); | ||
|
||
const cmp = wrapper.findComponent(Page1); | ||
expect(cmp.classes('ion-page')).toBe(true); | ||
expect(cmp.classes('custom-class')).toBe(true); | ||
}); | ||
}) |