mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 07:41:51 +08:00
test: add failing tests
This commit is contained in:
@ -2,6 +2,7 @@ import { h } from '@stencil/core';
|
|||||||
import { newSpecPage } from '@stencil/core/testing';
|
import { newSpecPage } from '@stencil/core/testing';
|
||||||
|
|
||||||
import { Modal } from '../../modal';
|
import { Modal } from '../../modal';
|
||||||
|
import { FOCUS_TRAP_DISABLE_CLASS } from '@utils/overlays';
|
||||||
|
|
||||||
describe('modal: htmlAttributes inheritance', () => {
|
describe('modal: htmlAttributes inheritance', () => {
|
||||||
it('should correctly inherit attributes on host', async () => {
|
it('should correctly inherit attributes on host', async () => {
|
||||||
@ -15,3 +16,26 @@ describe('modal: htmlAttributes inheritance', () => {
|
|||||||
await expect(modal.getAttribute('data-testid')).toBe('basic-modal');
|
await expect(modal.getAttribute('data-testid')).toBe('basic-modal');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('modal: focus trap', () => {
|
||||||
|
it('should set the focus trap class when disabled', async () => {
|
||||||
|
const page = await newSpecPage({
|
||||||
|
components: [Modal],
|
||||||
|
template: () => <ion-modal focusTrap={false} overlayIndex={1}></ion-modal>,
|
||||||
|
});
|
||||||
|
|
||||||
|
const modal = page.body.querySelector('ion-modal')!;
|
||||||
|
|
||||||
|
expect(modal.classList.contains(FOCUS_TRAP_DISABLE_CLASS)).toBe(true);
|
||||||
|
});
|
||||||
|
it('should not set the focus trap class by default', async () => {
|
||||||
|
const page = await newSpecPage({
|
||||||
|
components: [Modal],
|
||||||
|
template: () => <ion-modal overlayIndex={1}></ion-modal>,
|
||||||
|
});
|
||||||
|
|
||||||
|
const modal = page.body.querySelector('ion-modal')!;
|
||||||
|
|
||||||
|
expect(modal.classList.contains(FOCUS_TRAP_DISABLE_CLASS)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import { newSpecPage } from '@stencil/core/testing';
|
|||||||
|
|
||||||
import { Popover } from '../../popover';
|
import { Popover } from '../../popover';
|
||||||
|
|
||||||
|
import { FOCUS_TRAP_DISABLE_CLASS } from '@utils/overlays';
|
||||||
|
|
||||||
describe('popover: htmlAttributes inheritance', () => {
|
describe('popover: htmlAttributes inheritance', () => {
|
||||||
it('should correctly inherit attributes on host', async () => {
|
it('should correctly inherit attributes on host', async () => {
|
||||||
const page = await newSpecPage({
|
const page = await newSpecPage({
|
||||||
@ -15,3 +17,26 @@ describe('popover: htmlAttributes inheritance', () => {
|
|||||||
await expect(popover.getAttribute('data-testid')).toBe('basic-popover');
|
await expect(popover.getAttribute('data-testid')).toBe('basic-popover');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('popover: focus trap', () => {
|
||||||
|
it('should set the focus trap class when disabled', async () => {
|
||||||
|
const page = await newSpecPage({
|
||||||
|
components: [Popover],
|
||||||
|
template: () => <ion-popover focusTrap={false} overlayIndex={1}></ion-popover>,
|
||||||
|
});
|
||||||
|
|
||||||
|
const popover = page.body.querySelector('ion-popover')!;
|
||||||
|
|
||||||
|
expect(popover.classList.contains(FOCUS_TRAP_DISABLE_CLASS)).toBe(true);
|
||||||
|
});
|
||||||
|
it('should not set the focus trap class by default', async () => {
|
||||||
|
const page = await newSpecPage({
|
||||||
|
components: [Popover],
|
||||||
|
template: () => <ion-popover overlayIndex={1}></ion-popover>,
|
||||||
|
});
|
||||||
|
|
||||||
|
const popover = page.body.querySelector('ion-popover')!;
|
||||||
|
|
||||||
|
expect(popover.classList.contains(FOCUS_TRAP_DISABLE_CLASS)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user