@volverjs/ui-vue 0.0.1-beta.2 → 0.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/Button/Button.test.d.ts +11 -0
- package/dist/test/expect.d.ts +13 -0
- package/dist/ui-vue.es.js +3 -3
- package/dist/ui-vue.umd.js +1 -1
- package/package.json +4 -2
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/stories/Breadcrumb/Breadcrumb.stories.mdx +0 -1
- package/src/stories/Button/Button.stories.mdx +2 -8
- package/src/stories/Button/Button.test.ts +57 -0
- package/src/stories/Button/ButtonBadge.stories.mdx +2 -1
- package/src/stories/Button/ButtonIcon.stories.mdx +3 -11
- package/src/stories/Button/ButtonIconPosition.stories.mdx +17 -14
- package/src/stories/Button/ButtonLink.stories.mdx +13 -44
- package/src/stories/Button/ButtonLoading.stories.mdx +22 -3
- package/src/stories/Button/ButtonModifiers.stories.mdx +30 -44
- package/src/stories/Button/ButtonVariant.stories.mdx +33 -51
- package/src/stories/volver-ui-vue.stories.mdx +2 -1
- package/src/test/expect.ts +52 -0
- package/src/test/types.d.ts +3 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect } from '@storybook/jest'
|
|
2
|
+
import { userEvent } from '@storybook/testing-library'
|
|
3
|
+
import { axe } from 'jest-axe'
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
7
|
+
namespace jest {
|
|
8
|
+
interface Matchers<R> {
|
|
9
|
+
toBeClicked: (expected?: HTMLElement) => CustomMatcherResult
|
|
10
|
+
}
|
|
11
|
+
interface Matchers<R> {
|
|
12
|
+
toHaveClass: (
|
|
13
|
+
className: string | string[],
|
|
14
|
+
expected?: HTMLElement
|
|
15
|
+
) => CustomMatcherResult
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
expect.extend({
|
|
21
|
+
async toBeClicked(element: HTMLElement) {
|
|
22
|
+
const result = {
|
|
23
|
+
pass: false,
|
|
24
|
+
message: () => "Click event don't works"
|
|
25
|
+
}
|
|
26
|
+
element.addEventListener('click', () => {
|
|
27
|
+
result.pass = true
|
|
28
|
+
result.message = () => `Click event works`
|
|
29
|
+
})
|
|
30
|
+
await userEvent.click(element)
|
|
31
|
+
return result
|
|
32
|
+
},
|
|
33
|
+
async toHaveNoViolations(element: HTMLElement) {
|
|
34
|
+
const results = await axe(element)
|
|
35
|
+
return {
|
|
36
|
+
pass: results.violations.length === 0,
|
|
37
|
+
message: () => 'Element has violations'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
async toHaveClass(element: HTMLElement, className: string | string[]) {
|
|
41
|
+
const classes = !Array.isArray(className) ? [className] : className
|
|
42
|
+
return {
|
|
43
|
+
pass: classes.every((cssClass) =>
|
|
44
|
+
element.classList.contains(cssClass)
|
|
45
|
+
),
|
|
46
|
+
message: () =>
|
|
47
|
+
`One of these clsses doesn't exist: ${classes.join(', ')}`
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export { expect }
|