-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/tabs): add additional navigation events (#669)
- Loading branch information
1 parent
9c9cb0e
commit d800f29
Showing
7 changed files
with
230 additions
and
13 deletions.
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
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
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,98 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test'; | ||
|
||
test('renders', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-tabs> | ||
<ix-tab-item>Item 1</ix-tab-item> | ||
<ix-tab-item>Item 2</ix-tab-item> | ||
<ix-tab-item>Item 3</ix-tab-item> | ||
</ix-tabs> | ||
`); | ||
const tabs = page.locator('ix-tabs'); | ||
const tab = page.locator('ix-tab-item').nth(0); | ||
|
||
await expect(tabs).toHaveClass(/hydrated/); | ||
await expect(tab).toHaveClass(/selected/); | ||
}); | ||
|
||
test('should change tab', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-tabs> | ||
<ix-tab-item>Item 1</ix-tab-item> | ||
<ix-tab-item>Item 2</ix-tab-item> | ||
<ix-tab-item>Item 3</ix-tab-item> | ||
</ix-tabs> | ||
`); | ||
const tabs = page.locator('ix-tabs'); | ||
const tab = page.locator('ix-tab-item').nth(2); | ||
|
||
await tab.click(); | ||
|
||
await expect(tabs).toHaveClass(/hydrated/); | ||
await expect(tab).toHaveClass(/selected/); | ||
}); | ||
|
||
test('should not change tab by tab click event', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-tabs> | ||
<ix-tab-item>Item 1</ix-tab-item> | ||
<ix-tab-item>Item 2</ix-tab-item> | ||
<ix-tab-item>Item 3</ix-tab-item> | ||
</ix-tabs> | ||
`); | ||
const tabs = page.locator('ix-tabs'); | ||
const firstTab = page.locator('ix-tab-item').nth(0); | ||
const lastTab = page.locator('ix-tab-item').nth(2); | ||
|
||
lastTab.evaluate((tabElement) => { | ||
tabElement.addEventListener('tabClick', (event) => event.preventDefault()); | ||
}); | ||
|
||
await lastTab.click(); | ||
|
||
await expect(tabs).toHaveClass(/hydrated/); | ||
await expect(firstTab).toHaveClass(/selected/); | ||
await expect(lastTab).not.toHaveClass(/selected/); | ||
}); | ||
|
||
test('should not change tab by tabs event', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-tabs> | ||
<ix-tab-item>Item 1</ix-tab-item> | ||
<ix-tab-item>Item 2</ix-tab-item> | ||
<ix-tab-item>Item 3</ix-tab-item> | ||
</ix-tabs> | ||
`); | ||
const tabs = page.locator('ix-tabs'); | ||
const firstTab = page.locator('ix-tab-item').nth(0); | ||
const lastTab = page.locator('ix-tab-item').nth(2); | ||
|
||
tabs.evaluate((tabElement) => { | ||
tabElement.addEventListener('selectedChange', (event) => | ||
event.preventDefault() | ||
); | ||
}); | ||
|
||
await lastTab.click(); | ||
|
||
await expect(tabs).toHaveClass(/hydrated/); | ||
await expect(firstTab).toHaveClass(/selected/); | ||
await expect(lastTab).not.toHaveClass(/selected/); | ||
}); |
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