test: add failing tests

This commit is contained in:
Liam DeBeasi
2024-04-11 10:26:57 -04:00
parent 1a4494199e
commit 6dfedec4c0
2 changed files with 49 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { h } from '@stencil/core';
import { newSpecPage } from '@stencil/core/testing';
import { Modal } from '../../modal';
import { FOCUS_TRAP_DISABLE_CLASS } from '@utils/overlays';
describe('modal: htmlAttributes inheritance', () => {
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');
});
});
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);
});
});

View File

@ -3,6 +3,8 @@ import { newSpecPage } from '@stencil/core/testing';
import { Popover } from '../../popover';
import { FOCUS_TRAP_DISABLE_CLASS } from '@utils/overlays';
describe('popover: htmlAttributes inheritance', () => {
it('should correctly inherit attributes on host', async () => {
const page = await newSpecPage({
@ -15,3 +17,26 @@ describe('popover: htmlAttributes inheritance', () => {
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);
});
});