diff --git a/packages/bee-q/src/components/tab-group/__tests__/bq-tab-group.e2e.ts b/packages/bee-q/src/components/tab-group/__tests__/bq-tab-group.e2e.ts index 9cb8c321e..20534a6f7 100644 --- a/packages/bee-q/src/components/tab-group/__tests__/bq-tab-group.e2e.ts +++ b/packages/bee-q/src/components/tab-group/__tests__/bq-tab-group.e2e.ts @@ -2,13 +2,14 @@ import { newE2EPage } from '@stencil/core/testing'; describe('bq-tab-group', () => { it('should render', async () => { - const page = await newE2EPage(); - await page.setContent(` + const page = await newE2EPage({ + html: ` Tab 1 Tab 2 - `); + `, + }); const element = await page.find('bq-tab-group'); @@ -16,13 +17,14 @@ describe('bq-tab-group', () => { }); it('should have shadow root', async () => { - const page = await newE2EPage(); - await page.setContent(` + const page = await newE2EPage({ + html: ` Tab 1 Tab 2 - `); + `, + }); const element = await page.find('bq-tab-group'); @@ -30,13 +32,14 @@ describe('bq-tab-group', () => { }); it('should change size of all tabs', async () => { - const page = await newE2EPage(); - await page.setContent(` + const page = await newE2EPage({ + html: ` Tab 1 Tab 2 - `); + `, + }); const element = await page.find('bq-tab'); @@ -44,13 +47,14 @@ describe('bq-tab-group', () => { }); it('should emit bqChange on tab click', async () => { - const page = await newE2EPage(); - await page.setContent(` + const page = await newE2EPage({ + html: ` Tab 1 Tab 2 - `); + `, + }); const bqFocus = await page.spyOnEvent('bqFocus'); const bqChange = await page.spyOnEvent('bqChange'); @@ -65,15 +69,16 @@ describe('bq-tab-group', () => { }); it('should emit bqChange on keyboard navigation', async () => { - const page = await newE2EPage(); - await page.setContent(` + const page = await newE2EPage({ + html: ` Tab 1 Tab 2 Tab 3 Tab 4 - `); + `, + }); const bqFocus = await page.spyOnEvent('bqFocus'); const bqChange = await page.spyOnEvent('bqChange'); @@ -89,4 +94,26 @@ describe('bq-tab-group', () => { expect(bqChange).toHaveReceivedEventTimes(3); expect(bqBlur).toHaveReceivedEventTimes(4); }); + + it('should change active tab if value is change externally', async () => { + const page = await newE2EPage({ + html: ` + + Tab 1 + Tab 2 + Tab 3 + Tab 4 + + `, + }); + + const element = await page.find('bq-tab-group'); + element.setAttribute('value', '2'); + + await page.waitForChanges(); + + const activeElement = await page.find('bq-tab[active]'); + + expect(activeElement).toEqualText('Tab 2'); + }); }); diff --git a/packages/bee-q/src/components/tab-group/bq-tab-group.tsx b/packages/bee-q/src/components/tab-group/bq-tab-group.tsx index f310b5b72..0b0fd4c83 100644 --- a/packages/bee-q/src/components/tab-group/bq-tab-group.tsx +++ b/packages/bee-q/src/components/tab-group/bq-tab-group.tsx @@ -61,6 +61,7 @@ export class BqTabGroup { } @Watch('size') + @Watch('value') checkPropValues() { validatePropValue(TAB_SIZE, 'medium', this.el, 'size');