-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core/menu-item): update title when slot changes (#539)
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
- Loading branch information
1 parent
2b7a170
commit a36e82a
Showing
18 changed files
with
208 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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. | ||
*/ | ||
@mixin ghost-hover-pressed { | ||
:host:not(.disabled):not(:disabled).hover, | ||
:host:not(.disabled):not(:disabled):hover { | ||
background-color: var(--theme-ghost--background--hover); | ||
} | ||
|
||
:host:not(.disabled):not(:disabled).active, | ||
:host:not(.disabled):not(:disabled):active { | ||
background-color: var(--theme-ghost--background--active); | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
packages/core/src/components/menu-item/test/menu-item.spec.tsx
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,64 @@ | ||
/* | ||
* 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 { newSpecPage } from '@stencil/core/testing'; | ||
import { MenuItem } from '../menu-item'; | ||
|
||
import { createMutationObserver } from '../../utils/mutation-observer'; | ||
jest.mock('../../utils/mutation-observer'); | ||
|
||
describe('ix-menu-item', () => { | ||
beforeEach(() => { | ||
//@ts-ignore | ||
createMutationObserver = jest.fn(() => ({ | ||
observe: jest.fn(), | ||
})); | ||
}); | ||
it('should have a title', async () => { | ||
const page = await newSpecPage({ | ||
components: [MenuItem], | ||
html: `<ix-menu-item>Example Title</ix-menu-item>`, | ||
}); | ||
|
||
await page.waitForChanges(); | ||
|
||
const item = page.doc.querySelector('ix-menu-item'); | ||
|
||
const li = item.shadowRoot.querySelector('li'); | ||
|
||
expect(li.title).toBe('Example Title'); | ||
}); | ||
|
||
it('should have a title from innerText', async () => { | ||
const page = await newSpecPage({ | ||
components: [MenuItem], | ||
html: `<ix-menu-item><span>Example Title</span></ix-menu-item>`, | ||
}); | ||
|
||
await page.waitForChanges(); | ||
|
||
const item = page.doc.querySelector('ix-menu-item'); | ||
|
||
const li = item.shadowRoot.querySelector('li'); | ||
|
||
expect(li.title).toBe('Example Title'); | ||
}); | ||
|
||
it('should change title after content change', async () => { | ||
const page = await newSpecPage({ | ||
components: [MenuItem], | ||
html: `<ix-menu-item>Example Title</ix-menu-item>`, | ||
}); | ||
|
||
await page.waitForChanges(); | ||
const item = page.doc.querySelector('ix-menu-item'); | ||
item.innerText = 'Updated Title'; | ||
const li = item.shadowRoot.querySelector('li'); | ||
expect(li.title).toStrictEqual('Example Title'); | ||
}); | ||
}); |
Oops, something went wrong.