-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(sbb-link): add visual tests (#2844)
- Loading branch information
1 parent
411dfb0
commit 51d1844
Showing
18 changed files
with
512 additions
and
167 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
78 changes: 78 additions & 0 deletions
78
src/elements/link/block-link-button/block-link-button.visual.spec.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,78 @@ | ||
import { html, nothing } from 'lit'; | ||
|
||
import { | ||
describeEach, | ||
describeViewports, | ||
visualDiffDefault, | ||
visualDiffStandardStates, | ||
} from '../../core/testing/private.js'; | ||
|
||
import './block-link-button.js'; | ||
|
||
describe(`sbb-block-link-button`, () => { | ||
const iconState = { | ||
iconPlacement: ['start', 'end'], | ||
slotted: [false, true], | ||
}; | ||
|
||
describeViewports({ viewports: ['zero', 'medium'] }, () => { | ||
for (const negative of [true, false]) { | ||
for (const state of visualDiffStandardStates) { | ||
it( | ||
state.name, | ||
state.with((setup) => { | ||
setup.withFixture( | ||
html`<sbb-block-link-button ?negative=${negative} | ||
>Travelcards & tickets</sbb-block-link-button | ||
>`, | ||
{ | ||
backgroundColor: negative ? 'var(--sbb-color-charcoal)' : undefined, | ||
}, | ||
); | ||
}), | ||
); | ||
} | ||
} | ||
|
||
describeEach(iconState, ({ iconPlacement, slotted }) => { | ||
it( | ||
visualDiffDefault.name, | ||
visualDiffDefault.with((setup) => { | ||
setup.withFixture(html` | ||
<sbb-block-link-button | ||
icon-name=${slotted ? nothing : 'chevron-small-right-small'} | ||
icon-placement=${iconPlacement} | ||
> | ||
${slotted | ||
? html`<sbb-icon slot="icon" name="chevron-small-left-small"></sbb-icon>` | ||
: nothing} | ||
Travelcards & tickets | ||
</sbb-block-link-button> | ||
`); | ||
}), | ||
); | ||
}); | ||
|
||
for (const size of ['xs', 's', 'm']) { | ||
it( | ||
`size=${size} ${visualDiffDefault.name}`, | ||
visualDiffDefault.with((setup) => { | ||
setup.withFixture( | ||
html`<sbb-block-link-button size=${size}>Travelcards & tickets</sbb-block-link-button>`, | ||
); | ||
}), | ||
); | ||
} | ||
|
||
it( | ||
`width=fixed ${visualDiffDefault.name}`, | ||
visualDiffDefault.with((setup) => { | ||
setup.withFixture( | ||
html`<sbb-block-link-button icon-name="chevron-small-right-small" style="width: 200px;"> | ||
A lot of link text to show what happens if there is not enough space. | ||
</sbb-block-link-button>`, | ||
); | ||
}), | ||
); | ||
}); | ||
}); |
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
81 changes: 81 additions & 0 deletions
81
src/elements/link/block-link-static/block-link-static.visual.spec.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,81 @@ | ||
import { html, nothing } from 'lit'; | ||
|
||
import { | ||
describeEach, | ||
describeViewports, | ||
visualDiffActive, | ||
visualDiffDefault, | ||
visualDiffHover, | ||
} from '../../core/testing/private.js'; | ||
|
||
import './block-link-static.js'; | ||
|
||
describe(`sbb-block-link-static`, () => { | ||
const iconState = { | ||
iconPlacement: ['start', 'end'], | ||
slotted: [false, true], | ||
}; | ||
|
||
describeViewports({ viewports: ['zero', 'medium'] }, () => { | ||
for (const negative of [true, false]) { | ||
for (const state of [visualDiffDefault, visualDiffActive, visualDiffHover]) { | ||
it( | ||
state.name, | ||
state.with((setup) => { | ||
setup.withFixture( | ||
html` <sbb-block-link-static ?negative="${negative}" | ||
>Travelcards & tickets</sbb-block-link-static | ||
>`, | ||
{ | ||
backgroundColor: negative ? 'var(--sbb-color-charcoal)' : undefined, | ||
}, | ||
); | ||
}), | ||
); | ||
} | ||
} | ||
|
||
describeEach(iconState, ({ iconPlacement, slotted }) => { | ||
it( | ||
visualDiffDefault.name, | ||
visualDiffDefault.with((setup) => { | ||
setup.withFixture(html` | ||
<sbb-block-link-static | ||
icon-name="${slotted ? nothing : 'chevron-small-right-small'}" | ||
icon-placement="${iconPlacement}" | ||
> | ||
${slotted | ||
? html` <sbb-icon slot="icon" name="chevron-small-left-small"></sbb-icon>` | ||
: nothing} | ||
Travelcards & tickets | ||
</sbb-block-link-static> | ||
`); | ||
}), | ||
); | ||
}); | ||
|
||
for (const size of ['xs', 's', 'm']) { | ||
it( | ||
`size=${size} ${visualDiffDefault.name}`, | ||
visualDiffDefault.with((setup) => { | ||
setup.withFixture( | ||
html` <sbb-block-link-static size="${size}" | ||
>Travelcards & tickets</sbb-block-link-static | ||
>`, | ||
); | ||
}), | ||
); | ||
} | ||
|
||
it( | ||
`width=fixed ${visualDiffDefault.name}`, | ||
visualDiffDefault.with((setup) => { | ||
setup.withFixture( | ||
html` <sbb-block-link-static icon-name="chevron-small-right-small" style="width: 200px;"> | ||
A lot of link text to show what happens if there is not enough space. | ||
</sbb-block-link-static>`, | ||
); | ||
}), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.