Skip to content

Commit d1e32f8

Browse files
committed
Address PR review feedback on breadcrumbs scaffolding
- Add LumoInjectionMixin to <vaadin-breadcrumbs> and <vaadin-breadcrumbs-item> for Lumo theming - Switch registry tests to the tagName.toLowerCase() pattern - Replace shadowRoot tests with snapshot tests under test/dom/ - Add breadcrumbs-item.test.js stub for item-specific logic
1 parent ed1c186 commit d1e32f8

8 files changed

Lines changed: 126 additions & 18 deletions

packages/breadcrumbs/src/vaadin-breadcrumbs-item.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { html, LitElement } from 'lit';
77
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
88
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
99
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
1011
import { breadcrumbsItemStyles } from './styles/vaadin-breadcrumbs-item-base-styles.js';
1112

1213
/**
@@ -16,7 +17,7 @@ import { breadcrumbsItemStyles } from './styles/vaadin-breadcrumbs-item-base-sty
1617
* @extends HTMLElement
1718
* @mixes ElementMixin
1819
*/
19-
class BreadcrumbsItem extends ElementMixin(PolylitMixin(LitElement)) {
20+
class BreadcrumbsItem extends ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))) {
2021
static get is() {
2122
return 'vaadin-breadcrumbs-item';
2223
}

packages/breadcrumbs/src/vaadin-breadcrumbs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { html, LitElement } from 'lit';
88
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
99
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
1010
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
11+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
1112
import { breadcrumbsStyles } from './styles/vaadin-breadcrumbs-base-styles.js';
1213

1314
/**
@@ -18,7 +19,7 @@ import { breadcrumbsStyles } from './styles/vaadin-breadcrumbs-base-styles.js';
1819
* @extends HTMLElement
1920
* @mixes ElementMixin
2021
*/
21-
class Breadcrumbs extends ElementMixin(PolylitMixin(LitElement)) {
22+
class Breadcrumbs extends ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))) {
2223
static get is() {
2324
return 'vaadin-breadcrumbs';
2425
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { expect } from '@vaadin/chai-plugins';
2+
import { fixtureSync } from '@vaadin/testing-helpers';
3+
import '../vaadin-breadcrumbs-item.js';
4+
5+
window.Vaadin ??= {};
6+
window.Vaadin.featureFlags ??= {};
7+
window.Vaadin.featureFlags.breadcrumbsComponent = true;
8+
9+
describe('vaadin-breadcrumbs-item', () => {
10+
let item;
11+
12+
beforeEach(() => {
13+
item = fixtureSync('<vaadin-breadcrumbs-item></vaadin-breadcrumbs-item>');
14+
});
15+
16+
describe('custom element definition', () => {
17+
let tagName;
18+
19+
beforeEach(() => {
20+
tagName = item.tagName.toLowerCase();
21+
});
22+
23+
it('should be defined in custom element registry', () => {
24+
expect(customElements.get(tagName)).to.be.ok;
25+
});
26+
27+
it('should have a valid static "is" getter', () => {
28+
expect(customElements.get(tagName).is).to.equal(tagName);
29+
});
30+
});
31+
});
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import { expect } from '@vaadin/chai-plugins';
2-
import { fixtureSync, nextRender } from '@vaadin/testing-helpers';
2+
import { fixtureSync } from '@vaadin/testing-helpers';
33
import '../vaadin-breadcrumbs.js';
4-
import '../vaadin-breadcrumbs-item.js';
54

65
window.Vaadin ??= {};
76
window.Vaadin.featureFlags ??= {};
87
window.Vaadin.featureFlags.breadcrumbsComponent = true;
98

109
describe('vaadin-breadcrumbs', () => {
11-
it('should register vaadin-breadcrumbs in the custom element registry', () => {
12-
expect(customElements.get('vaadin-breadcrumbs')).to.be.ok;
13-
});
10+
let breadcrumbs;
1411

15-
it('should register vaadin-breadcrumbs-item in the custom element registry', () => {
16-
expect(customElements.get('vaadin-breadcrumbs-item')).to.be.ok;
12+
beforeEach(() => {
13+
breadcrumbs = fixtureSync('<vaadin-breadcrumbs></vaadin-breadcrumbs>');
1714
});
1815

19-
it('should attach the breadcrumbs with a non-null shadowRoot', async () => {
20-
const breadcrumbs = fixtureSync('<vaadin-breadcrumbs></vaadin-breadcrumbs>');
21-
await nextRender();
22-
expect(breadcrumbs.shadowRoot).to.not.be.null;
23-
});
16+
describe('custom element definition', () => {
17+
let tagName;
18+
19+
beforeEach(() => {
20+
tagName = breadcrumbs.tagName.toLowerCase();
21+
});
22+
23+
it('should be defined in custom element registry', () => {
24+
expect(customElements.get(tagName)).to.be.ok;
25+
});
2426

25-
it('should attach the item with a non-null shadowRoot', async () => {
26-
const item = fixtureSync('<vaadin-breadcrumbs-item></vaadin-breadcrumbs-item>');
27-
await nextRender();
28-
expect(item.shadowRoot).to.not.be.null;
27+
it('should have a valid static "is" getter', () => {
28+
expect(customElements.get(tagName).is).to.equal(tagName);
29+
});
2930
});
3031
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* @web/test-runner snapshot v1 */
2+
export const snapshots = {};
3+
4+
snapshots["vaadin-breadcrumbs-item host default"] =
5+
`<vaadin-breadcrumbs-item>
6+
</vaadin-breadcrumbs-item>
7+
`;
8+
/* end snapshot vaadin-breadcrumbs-item host default */
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* @web/test-runner snapshot v1 */
2+
export const snapshots = {};
3+
4+
snapshots["vaadin-breadcrumbs host default"] =
5+
`<vaadin-breadcrumbs>
6+
</vaadin-breadcrumbs>
7+
`;
8+
/* end snapshot vaadin-breadcrumbs host default */
9+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect } from '@vaadin/chai-plugins';
2+
import { fixtureSync, nextRender } from '@vaadin/testing-helpers';
3+
import '../../src/vaadin-breadcrumbs-item.js';
4+
5+
window.Vaadin ??= {};
6+
window.Vaadin.featureFlags ??= {};
7+
window.Vaadin.featureFlags.breadcrumbsComponent = true;
8+
9+
describe('vaadin-breadcrumbs-item', () => {
10+
let item;
11+
12+
beforeEach(async () => {
13+
item = fixtureSync('<vaadin-breadcrumbs-item></vaadin-breadcrumbs-item>');
14+
await nextRender();
15+
});
16+
17+
describe('host', () => {
18+
it('default', async () => {
19+
await expect(item).dom.to.equalSnapshot();
20+
});
21+
});
22+
23+
describe('shadow', () => {
24+
it('default', async () => {
25+
await expect(item).shadowDom.to.equalSnapshot();
26+
});
27+
});
28+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect } from '@vaadin/chai-plugins';
2+
import { fixtureSync, nextRender } from '@vaadin/testing-helpers';
3+
import '../../src/vaadin-breadcrumbs.js';
4+
5+
window.Vaadin ??= {};
6+
window.Vaadin.featureFlags ??= {};
7+
window.Vaadin.featureFlags.breadcrumbsComponent = true;
8+
9+
describe('vaadin-breadcrumbs', () => {
10+
let breadcrumbs;
11+
12+
beforeEach(async () => {
13+
breadcrumbs = fixtureSync('<vaadin-breadcrumbs></vaadin-breadcrumbs>');
14+
await nextRender();
15+
});
16+
17+
describe('host', () => {
18+
it('default', async () => {
19+
await expect(breadcrumbs).dom.to.equalSnapshot();
20+
});
21+
});
22+
23+
describe('shadow', () => {
24+
it('default', async () => {
25+
await expect(breadcrumbs).shadowDom.to.equalSnapshot();
26+
});
27+
});
28+
});

0 commit comments

Comments
 (0)