-
+
${chipContent}
${titleContent}
${description}
diff --git a/src/elements/teaser/teaser.visual.spec.ts b/src/elements/teaser/teaser.visual.spec.ts
index 1c79c87128..4ac11e763f 100644
--- a/src/elements/teaser/teaser.visual.spec.ts
+++ b/src/elements/teaser/teaser.visual.spec.ts
@@ -12,6 +12,8 @@ import {
import { waitForImageReady } from '../core/testing.js';
import './teaser.js';
+import '../chip-label.js';
+import '../container.js';
import '../image.js';
const imageUrl = import.meta.resolve('../core/testing/assets/placeholder-image.png');
@@ -27,6 +29,37 @@ describe(`sbb-teaser`, () => {
const longChip: string =
'This is a chip which has a very long content and should receive ellipsis.';
+ const imgCases = [
+ {
+ title: 'imageSlot=sbb-image',
+ imgSelector: 'sbb-image',
+ imgTemplate: () => html``,
+ },
+ {
+ title: 'imageSlot=img',
+ imgSelector: 'img',
+ imgTemplate: () => html``,
+ },
+ {
+ title: 'imageSlot=figure_and_sbb-image',
+ imgSelector: 'sbb-image',
+ imgTemplate: () =>
+ html``,
+ },
+ {
+ title: 'imageSlot=figure_and_img',
+ imgSelector: 'img',
+ imgTemplate: () =>
+ html``,
+ },
+ ];
+
const visualStates = {
hasChip: [false, true],
withLongContent: [false, true],
@@ -41,28 +74,31 @@ describe(`sbb-teaser`, () => {
describeViewports({ viewports: [screenCombination.viewport] }, () => {
for (const alignment of screenCombination.alignments) {
describe(`alignment=${alignment}`, () => {
- for (const visualDiffStandardState of [
- visualDiffDefault,
- visualDiffFocus,
- visualDiffHover,
- ]) {
- it(
- `state=${visualDiffStandardState.name}`,
- visualDiffStandardState.with(async (setup) => {
- await setup.withFixture(
- html`
-
-
- This is a paragraph
-
- `,
- { maxWidth: '760px' },
+ for (const imgCase of imgCases) {
+ describe(imgCase.title, () => {
+ for (const visualDiffStandardState of [
+ visualDiffDefault,
+ visualDiffFocus,
+ visualDiffHover,
+ ]) {
+ it(
+ `state=${visualDiffStandardState.name}`,
+ visualDiffStandardState.with(async (setup) => {
+ await setup.withFixture(
+ html`
+
+ ${imgCase.imgTemplate()} This is a paragraph
+
+ `,
+ { maxWidth: '760px' },
+ );
+ await waitForImageReady(
+ setup.snapshotElement.querySelector(imgCase.imgSelector)!,
+ );
+ }),
);
- await waitForImageReady(setup.snapshotElement.querySelector('img')!);
- }),
- );
+ }
+ });
}
describeEach(visualStates, ({ hasChip, withLongContent }) => {
@@ -80,9 +116,9 @@ describe(`sbb-teaser`, () => {
${withLongContent ? loremIpsum : 'This is a paragraph'}
@@ -94,93 +130,44 @@ describe(`sbb-teaser`, () => {
}),
);
});
-
- it(
- `longChip=true`,
- visualDiffDefault.with(async (setup) => {
- await setup.withFixture(
- html`
-
-
- This is a paragraph
-
- `,
- { maxWidth: '760px' },
- );
- await waitForImageReady(setup.snapshotElement.querySelector('img')!);
- }),
- );
-
- it(
- `list=true`,
- visualDiffDefault.with(async (setup) => {
- const count = 5;
- await setup.withFixture(html`
-
- ${repeat(
- new Array(count),
- (_, i) => html`
- -
-
-
- This is the paragraph n.${i + 1}
-
-
- `,
- )}
-
- `);
- await Promise.all(
- new Array(count).map((_, i) =>
- waitForImageReady(setup.snapshotElement.querySelector(`#img${i}`)!),
- ),
- );
- }),
- );
});
}
it(
'grid with sbb-image',
visualDiffDefault.with(async (setup) => {
+ const count = 2;
await setup.withFixture(html`
-
- ${repeat(
- new Array(2),
- () => html`
-
-
- This is a paragraph
-
- `,
- )}
-
+
+
+ ${repeat(
+ new Array(count),
+ (_, i) => html`
+
+
+ This is a paragraph
+
+ `,
+ )}
+
+
`);
- await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
+
+ await Promise.all(
+ new Array(count).map((_, i) =>
+ waitForImageReady(setup.snapshotElement.querySelector(`#img${i}`)!),
+ ),
+ );
}),
);
@@ -200,6 +187,28 @@ describe(`sbb-teaser`, () => {
await waitForImageReady(setup.snapshotElement.querySelector('sbb-image')!);
}),
);
+
+ it(
+ `longChip`,
+ visualDiffDefault.with(async (setup) => {
+ await setup.withFixture(
+ html`
+
+
+ This is a paragraph
+
+ `,
+ { maxWidth: '760px' },
+ );
+ await waitForImageReady(setup.snapshotElement.querySelector('img')!);
+ }),
+ );
});
}
});