-
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.
fix(core/input-group): detect inital value padding (#803)
- Loading branch information
1 parent
51ae5b2
commit 17efd6e
Showing
2 changed files
with
122 additions
and
10 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
101 changes: 101 additions & 0 deletions
101
packages/core/src/components/input-group/tests/input-group.ct.ts
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,101 @@ | ||
/* | ||
* 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 thi s source tree. | ||
*/ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test'; | ||
|
||
test('renders', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-input-group> | ||
<input class="parameter-value" type="text" value="Some initial value" /> | ||
</ix-input-group> | ||
`); | ||
|
||
const group = page.locator('ix-input-group'); | ||
await expect(group).toHaveClass(/hydrated/); | ||
|
||
const input = group.locator('input'); | ||
await expect(input).toHaveCSS('padding-left', '8px'); | ||
await expect(input).toHaveCSS('padding-right', '15px'); | ||
}); | ||
|
||
test('initial padding start', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-input-group> | ||
<span slot="input-start"> | ||
<ix-icon name="eye" size="16"></ix-icon> | ||
</span> | ||
<input class="parameter-value" type="text" value="Some initial value" /> | ||
</ix-input-group> | ||
`); | ||
|
||
const group = page.locator('ix-input-group'); | ||
await expect(group).toHaveClass(/hydrated/); | ||
|
||
const input = group.locator('input'); | ||
await expect(input).toHaveCSS('padding-left', '31px'); | ||
await expect(input).toHaveCSS('padding-right', '15px'); | ||
}); | ||
|
||
test('initial padding end', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-input-group> | ||
<span slot="input-start"> | ||
<ix-icon name="eye" size="16"></ix-icon> | ||
</span> | ||
<span slot="input-end"> | ||
<ix-icon name="eye" size="16"></ix-icon> | ||
</span> | ||
<input class="parameter-value" type="text" value="Some initial value" /> | ||
</ix-input-group> | ||
`); | ||
|
||
const group = page.locator('ix-input-group'); | ||
await expect(group).toHaveClass(/hydrated/); | ||
|
||
const input = group.locator('input'); | ||
await expect(input).toHaveCSS('padding-left', '31px'); | ||
await expect(input).toHaveCSS('padding-right', '31px'); | ||
}); | ||
|
||
test('update padding end', async ({ mount, page }) => { | ||
await mount(` | ||
<ix-input-group> | ||
<input class="parameter-value" type="text" value="Some initial value" /> | ||
</ix-input-group> | ||
`); | ||
|
||
const group = page.locator('ix-input-group'); | ||
await expect(group).toHaveClass(/hydrated/); | ||
|
||
const input = group.locator('input'); | ||
await expect(input).toHaveCSS('padding-left', '8px'); | ||
await expect(input).toHaveCSS('padding-right', '15px'); | ||
|
||
await group.evaluate((group: HTMLElement) => { | ||
const startElement = document.createElement('DIV'); | ||
startElement.style.height = '1px'; | ||
startElement.style.width = '40px'; | ||
startElement.slot = 'input-start'; | ||
group.appendChild(startElement); | ||
}); | ||
|
||
await expect(input).toHaveCSS('padding-left', '55px'); | ||
await expect(input).toHaveCSS('padding-right', '15px'); | ||
|
||
await group.evaluate((group: HTMLElement) => { | ||
const endElement = document.createElement('DIV'); | ||
endElement.style.height = '1px'; | ||
endElement.style.width = '50px'; | ||
endElement.slot = 'input-end'; | ||
group.appendChild(endElement); | ||
}); | ||
|
||
await expect(input).toHaveCSS('padding-left', '55px'); | ||
await expect(input).toHaveCSS('padding-right', '65px'); | ||
}); |