Skip to content

Commit

Permalink
fix(accordion): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
skhamvon authored and dpellier committed Nov 10, 2023
1 parent 200e5c7 commit 121eaf3
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DEFAULT_ATTRIBUTE } from './constants/default-attributes';
describe('e2e:osds-accordion', () => {
let page: E2EPage;
let el: E2EElement;
let summarySlot : E2EElement;

async function setup({ attributes = {}, html = '' }: { attributes?: Partial<OdsAccordionAttribute>, html?: string } = {}) {
const stringAttributes = odsComponentAttributes2StringAttributes<OdsAccordionAttribute>(attributes, DEFAULT_ATTRIBUTE);
Expand All @@ -22,6 +23,7 @@ describe('e2e:osds-accordion', () => {
`);
await page.evaluate(() => document.body.style.setProperty('margin', '4px'));
el = await page.find('osds-accordion');
summarySlot = await page.find('osds-accordion >>> summary');
}

describe('defaults', () => {
Expand Down Expand Up @@ -54,5 +56,27 @@ describe('e2e:osds-accordion', () => {
expect(details?.getAttribute('open')).toBe('');
expect(componentOpened).toBe(true);
});

it('should not opened if disabled', async() => {
const content = `
<span slot='summary'>Lorem ipsum</span>
Lorem ipsum
`
await setup({
attributes: { opened: false, disabled: true },
html : content
});
await page.waitForChanges();

await summarySlot.focus();
await page.waitForChanges();

await page.keyboard.press('Space');
await page.waitForChanges();

const componentOpened = await el.getProperty('opened');

expect(componentOpened).toBe(false);
});
});
});

0 comments on commit 121eaf3

Please sign in to comment.