-
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.
Merge branch 'refs/heads/main' into feat/migration-notification
- Loading branch information
Showing
14 changed files
with
557 additions
and
159 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
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
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,95 @@ | ||
import { html, nothing, type TemplateResult } from 'lit'; | ||
import { repeat } from 'lit/directives/repeat.js'; | ||
|
||
import type { visualRegressionFixture } from '../../core/testing/private.js'; | ||
import { | ||
describeEach, | ||
describeViewports, | ||
visualDiffDefault, | ||
visualDiffFocus, | ||
visualDiffHover, | ||
} from '../../core/testing/private.js'; | ||
|
||
import './menu-button.js'; | ||
|
||
describe(`sbb-menu-button`, () => { | ||
const defaultArgs = { | ||
amount: 123 as number | undefined, | ||
iconName: 'tick-small', | ||
label: 'Button', | ||
disabled: false, | ||
slottedIcon: false, | ||
}; | ||
|
||
const template = ({ | ||
amount, | ||
iconName, | ||
label, | ||
disabled, | ||
slottedIcon, | ||
}: typeof defaultArgs): TemplateResult => html` | ||
${repeat( | ||
new Array(3), | ||
(_, index) => html` | ||
<sbb-menu-button | ||
amount=${amount || nothing} | ||
icon-name=${iconName || nothing} | ||
?disabled=${disabled} | ||
> | ||
${label} ${index} | ||
${slottedIcon ? html`<sbb-icon slot="icon" name="pie-small"></sbb-icon>` : nothing} | ||
</sbb-menu-button> | ||
`, | ||
)} | ||
`; | ||
|
||
const state = { | ||
amount: [undefined, 123], | ||
slottedIcon: [false, true], | ||
}; | ||
|
||
const wrapperStyles: Parameters<typeof visualRegressionFixture>[1] = { | ||
backgroundColor: 'var(--sbb-color-black)', | ||
maxWidth: '256px', | ||
}; | ||
|
||
describeViewports({ viewports: ['zero', 'medium'] }, () => { | ||
for (const visualDiffState of [visualDiffDefault, visualDiffHover, visualDiffFocus]) { | ||
it( | ||
visualDiffState.name, | ||
visualDiffState.with(async (setup) => { | ||
await setup.withFixture(template(defaultArgs), wrapperStyles); | ||
}), | ||
); | ||
|
||
it( | ||
`disabled ${visualDiffState.name}`, | ||
visualDiffState.with(async (setup) => { | ||
await setup.withFixture(template({ ...defaultArgs, disabled: true }), wrapperStyles); | ||
}), | ||
); | ||
|
||
it( | ||
`long label ${visualDiffState.name}`, | ||
visualDiffState.with(async (setup) => { | ||
await setup.withFixture( | ||
template({ | ||
...defaultArgs, | ||
label: 'Button lorem ipsum dolor sit amet, consectetur adipiscing elit', | ||
}), | ||
wrapperStyles, | ||
); | ||
}), | ||
); | ||
} | ||
|
||
describeEach(state, ({ amount, slottedIcon }) => { | ||
it( | ||
visualDiffDefault.name, | ||
visualDiffDefault.with(async (setup) => { | ||
await setup.withFixture(template({ ...defaultArgs, amount, slottedIcon }), wrapperStyles); | ||
}), | ||
); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.