-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathBase.stories.ts
More file actions
80 lines (70 loc) · 1.94 KB
/
Base.stories.ts
File metadata and controls
80 lines (70 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import type { Meta, StoryObj } from '@storybook-vue/nuxt'
import { expect, fn, userEvent } from 'storybook/test'
import Component from './Base.vue'
const meta = {
component: Component,
tags: ['autodocs'],
argTypes: {
disabled: { control: 'boolean' },
size: {
control: 'select',
options: ['small', 'medium', 'large'],
},
noCorrect: {
control: 'boolean',
},
onFocus: {
action: 'focus',
},
onBlur: {
action: 'blur',
},
},
} satisfies Meta<typeof Component>
export default meta
type Story = StoryObj<typeof meta>
export const Snapshot: Story = {
render: () => ({
template: `
<div style="display: flex; flex-direction: column; gap: 1rem; padding: 1rem;">
<Component size="small" model-value="Small input" />
<Component size="medium" model-value="Medium input" />
<Component size="large" model-value="Large input" />
<Component size="large" model-value="disabled" disabled />
</div>
`,
components: { Component },
}),
}
export const Event: Story = {
args: {
onFocus: fn(),
onBlur: fn(),
},
play: async ({ args, canvas }) => {
const input = canvas.getByRole('textbox')
await userEvent.click(input)
await expect(args.onFocus).toHaveBeenCalled()
await userEvent.tab()
await expect(args.onBlur).toHaveBeenCalled()
},
}
export const Disable: Story = {
args: { disabled: true },
play: async ({ canvas }) => {
const input = canvas.getByRole('textbox')
await expect(input).toBeDisabled()
},
}
export const NoCorrect: Story = {
args: {
noCorrect: true,
},
play: async ({ canvas }) => {
const input = canvas.getByRole('textbox')
await expect(input).toHaveAttribute('autocapitalize', 'off')
await expect(input).toHaveAttribute('autocorrect', 'off')
await expect(input).toHaveAttribute('autocomplete', 'off')
await expect(input).toHaveAttribute('spellcheck', 'false')
},
}