Skip to content

Commit 0a7efcf

Browse files
committed
test(input): add tests for input components
1 parent 778bb17 commit 0a7efcf

File tree

304 files changed

+4256
-3619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

304 files changed

+4256
-3619
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ parserOptions:
1515
sourceType: module
1616
plugins:
1717
- '@typescript-eslint'
18-
rules:
18+
rules:
1919
'@typescript-eslint/member-delimiter-style':
2020
- error
2121
- multiline:

.prettierrc.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# .prettierrc or .prettierrc.yaml
2-
trailingComma: "es5"
2+
trailingComma: 'es5'
33
tabWidth: 2
44
semi: false
5-
singleQuote: true
5+
singleQuote: false

components.d.ts

+147-146
Large diffs are not rendered by default.

examples/vue-ssr/src/main.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import App from './App.vue'
2-
import viteSSR from 'vite-ssr'
3-
import { createHead } from '@vueuse/head'
4-
import routes from 'virtual:generated-pages'
5-
import Chakra, { chakra } from '@chakra-ui/vue-next'
6-
import { hydrate } from '@emotion/css'
7-
import { domElements } from '@chakra-ui/vue-system'
8-
import { extractCritical } from '@emotion/server'
1+
import App from "./App.vue"
2+
import viteSSR from "vite-ssr"
3+
import { createHead } from "@vueuse/head"
4+
import routes from "virtual:generated-pages"
5+
import Chakra, { chakra } from "@chakra-ui/vue-next"
6+
import { hydrate } from "@emotion/css"
7+
import { domElements } from "@chakra-ui/vue-system"
8+
import { extractCritical } from "@emotion/server"
99

1010
/**
1111
*
@@ -16,12 +16,12 @@ import { extractCritical } from '@emotion/server'
1616
const injectCritical = (html: string, ids: string[], css: string) =>
1717
html
1818
.replace(
19-
'</title>\n',
19+
"</title>\n",
2020
`</title>\n<script>window.$emotionSSRIds=${JSON.stringify(
2121
ids
2222
)}</script>\n`
2323
)
24-
.replace('</head>\n', `<style>${css}</style>\n</head>\n`)
24+
.replace("</head>\n", `<style>${css}</style>\n</head>\n`)
2525

2626
export default viteSSR(App, { routes }, ({ app, isClient }) => {
2727
/* custom logic */

examples/vue-ssr/src/shims-vue.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
declare module '*.vue' {
2-
import { DefineComponent } from 'vue'
1+
declare module "*.vue" {
2+
import { DefineComponent } from "vue"
33
const component: DefineComponent<{}, {}, any>
44
export default component
55
}
66

7-
declare module 'virtual:generated-pages' {
8-
import { RouteRecordRaw } from 'vue-router'
7+
declare module "virtual:generated-pages" {
8+
import { RouteRecordRaw } from "vue-router"
99
const routes: RouteRecordRaw[]
1010
export default routes
1111
}

examples/vue-ssr/vite.config.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { defineConfig } from 'vite'
2-
import vue from '@vitejs/plugin-vue'
3-
import viteSSR from 'vite-ssr/plugin.js'
4-
import Pages from 'vite-plugin-pages'
5-
import Components from 'unplugin-vue-components'
6-
import { componentResolver } from '@chakra-ui/vue-auto-import'
1+
import { defineConfig } from "vite"
2+
import vue from "@vitejs/plugin-vue"
3+
import viteSSR from "vite-ssr/plugin.js"
4+
import Pages from "vite-plugin-pages"
5+
import Components from "unplugin-vue-components"
6+
import { componentResolver } from "@chakra-ui/vue-auto-import"
77

88
// https://vitejs.dev/config/
99
export default defineConfig({
1010
plugins: [
1111
vue(),
1212
viteSSR(),
1313
Pages({
14-
pagesDir: 'src/pages',
15-
extensions: ['vue', 'ts', 'tsx'],
14+
pagesDir: "src/pages",
15+
extensions: ["vue", "ts", "tsx"],
1616
}),
1717
Components({
1818
customComponentResolvers: [componentResolver],

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@
150150
"tinycolor2": "^1.4.2",
151151
"ts-jest": "^26.5.0",
152152
"ts-node": "^9.0.0",
153-
"typescript": "^4.4.3",
153+
"typescript": "^4.5.4",
154154
"unplugin-vue-components": "^0.14.0",
155-
"vite": "^2.7.1",
155+
"vite": "^2.7.4",
156156
"vite-plugin-mdx-vue": "^1.1.3",
157157
"vite-plugin-pages": "^0.18.2",
158158
"vite-plugin-vue-layouts": "^0.3.1",

packages/c-accordion/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './src'
1+
export * from "./src"

packages/c-accordion/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { h, defineComponent, PropType } from 'vue'
2-
import { chakra, DOMElements } from '@chakra-ui/vue-system'
1+
import { h, defineComponent, PropType } from "vue"
2+
import { chakra, DOMElements } from "@chakra-ui/vue-system"
33

44
const CAccordion = defineComponent({
55
props: {
66
as: {
77
type: [String] as PropType<DOMElements>,
8-
default: 'div',
8+
default: "div",
99
},
1010
},
1111
setup(props, { slots, attrs }) {
1212
return () =>
13-
h(chakra(props.as, { label: 'accordion' }), { ...attrs }, slots)
13+
h(chakra(props.as, { label: "accordion" }), { ...attrs }, slots)
1414
},
1515
})
1616

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import CAccordion from '../src'
2-
import { h } from 'vue'
1+
import CAccordion from "../src"
2+
import { h } from "vue"
33

4-
it('should render properly', () => {
4+
it("should render properly", () => {
55
cy.mount(<CAccordion></CAccordion>)
66
})

packages/c-alert/examples/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * as BaseAlert from './base-alert.vue'
2-
export * as WithAccent from './with-accent.vue'
3-
export * as WithIcon from './with-icon.vue'
4-
export * as WithStatus from './with-status.vue'
5-
export * as WithTitle from './with-title.vue'
1+
export * as BaseAlert from "./base-alert.vue"
2+
export * as WithAccent from "./with-accent.vue"
3+
export * as WithIcon from "./with-icon.vue"
4+
export * as WithStatus from "./with-status.vue"
5+
export * as WithTitle from "./with-title.vue"

packages/c-alert/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './src'
1+
export * from "./src"

packages/c-alert/src/alert.ts

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, defineComponent, PropType, computed, ComputedRef } from 'vue'
1+
import { h, defineComponent, PropType, computed, ComputedRef } from "vue"
22
import {
33
chakra,
44
ThemingProps,
@@ -7,40 +7,40 @@ import {
77
StylesProvider,
88
DOMElements,
99
SystemStyleObject,
10-
} from '@chakra-ui/vue-system'
11-
import { createContext } from '@chakra-ui/vue-utils'
12-
import { CIcon } from '@chakra-ui/c-icon'
10+
} from "@chakra-ui/vue-system"
11+
import { createContext } from "@chakra-ui/vue-utils"
12+
import { CIcon } from "@chakra-ui/c-icon"
1313

1414
const STATUSES = {
1515
info: {
16-
colorScheme: 'blue',
17-
icon: 'info',
16+
colorScheme: "blue",
17+
icon: "info",
1818
},
1919
success: {
20-
colorScheme: 'green',
21-
icon: 'check-circle',
20+
colorScheme: "green",
21+
icon: "check-circle",
2222
},
2323
warning: {
24-
colorScheme: 'orange',
25-
icon: 'warning-alt',
24+
colorScheme: "orange",
25+
icon: "warning-alt",
2626
},
2727
error: {
28-
colorScheme: 'red',
29-
icon: 'warning',
28+
colorScheme: "red",
29+
icon: "warning",
3030
},
3131
}
3232

3333
type AlertStatus = keyof typeof STATUSES
34-
export type AlertVariant = 'solid' | 'subtle' | 'left-accent' | 'top-accent'
34+
export type AlertVariant = "solid" | "subtle" | "left-accent" | "top-accent"
3535

3636
interface AlertContext {
3737
status: ComputedRef<AlertStatus>
3838
}
3939

4040
const [AlertProvider, useAlertContext] = createContext<AlertContext>({
41-
name: 'AlertContext',
41+
name: "AlertContext",
4242
errorMessage:
43-
'useAlertContext: `context` is undefined. Seems you forgot to wrap alert components in `<c-alert />`',
43+
"useAlertContext: `context` is undefined. Seems you forgot to wrap alert components in `<c-alert />`",
4444
})
4545

4646
/**
@@ -50,15 +50,15 @@ const [AlertProvider, useAlertContext] = createContext<AlertContext>({
5050
* It also provides state and context to it's compound components
5151
*/
5252
export const CAlert = defineComponent({
53-
name: 'CAlert',
53+
name: "CAlert",
5454
props: {
5555
as: {
5656
type: [String, Object] as PropType<DOMElements>,
57-
default: 'div',
57+
default: "div",
5858
},
5959
status: {
6060
type: [String] as PropType<AlertStatus>,
61-
default: 'info',
61+
default: "info",
6262
},
6363
colorScheme: {
6464
type: [String] as PropType<string>,
@@ -68,7 +68,7 @@ export const CAlert = defineComponent({
6868
},
6969
variant: {
7070
type: [String] as PropType<AlertVariant>,
71-
default: 'solid',
71+
default: "solid",
7272
},
7373
},
7474
setup(props, { slots, attrs }) {
@@ -82,23 +82,23 @@ export const CAlert = defineComponent({
8282
}))
8383

8484
AlertProvider({ status: computed(() => props.status) })
85-
const styles = useMultiStyleConfig('Alert', themingProps.value)
85+
const styles = useMultiStyleConfig("Alert", themingProps.value)
8686
StylesProvider(styles)
8787

8888
const alertStyles = computed<SystemStyleObject>(() => ({
89-
width: '100%',
90-
display: 'flex',
91-
alignItems: 'center',
92-
position: 'relative',
93-
overflow: 'hidden',
89+
width: "100%",
90+
display: "flex",
91+
alignItems: "center",
92+
position: "relative",
93+
overflow: "hidden",
9494
...styles.value.container,
9595
}))
9696

9797
return () => {
9898
return h(
99-
chakra(props.as, { label: 'alert' }),
99+
chakra(props.as, { label: "alert" }),
100100
{
101-
role: 'alert',
101+
role: "alert",
102102
...alertStyles.value,
103103
...attrs,
104104
},
@@ -114,13 +114,13 @@ export const CAlert = defineComponent({
114114
* The title component for alerts
115115
*/
116116
export const CAlertTitle = defineComponent({
117-
name: 'CAlertTitle',
117+
name: "CAlertTitle",
118118
setup(_, { attrs, slots }) {
119119
return () => {
120120
const styles = useStyles()
121121

122122
return h(
123-
chakra('div', { label: 'alert__title' }),
123+
chakra("div", { label: "alert__title" }),
124124
{
125125
...styles.value.title,
126126
...attrs,
@@ -137,12 +137,12 @@ export const CAlertTitle = defineComponent({
137137
* The description component for alerts
138138
*/
139139
export const CAlertDescription = defineComponent({
140-
name: 'CAlertDescription',
140+
name: "CAlertDescription",
141141
setup(_, { attrs, slots }) {
142142
const styles = useStyles()
143143
return () => {
144144
return h(
145-
chakra('div', { label: 'alert__description' }),
145+
chakra("div", { label: "alert__description" }),
146146
{
147147
...styles.value.description,
148148
...attrs,
@@ -159,7 +159,7 @@ export const CAlertDescription = defineComponent({
159159
* The Icon component for alerts
160160
*/
161161
export const CAlertIcon = defineComponent({
162-
name: 'CAlertIcon',
162+
name: "CAlertIcon",
163163
props: {
164164
icon: {
165165
type: [String] as PropType<string>,
@@ -173,7 +173,7 @@ export const CAlertIcon = defineComponent({
173173

174174
return () => {
175175
return h(CIcon, {
176-
class: 'alert__icon',
176+
class: "alert__icon",
177177
name: alertIcon.value,
178178
...styles.value.icon,
179179
...attrs,

packages/c-alert/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './alert'
1+
export * from "./alert"

packages/c-alert/tests/c-alert.cy.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import * as Examples from '../examples'
2-
import { h } from 'vue'
3-
import { CAlert, CAlertDescription, CAlertIcon, CAlertTitle } from '../src'
1+
import * as Examples from "../examples"
2+
import { h } from "vue"
3+
import { CAlert, CAlertDescription, CAlertIcon, CAlertTitle } from "../src"
44

5-
describe('Alert Examples', () => {
5+
describe("Alert Examples", () => {
66
Object.entries(Examples).map(([name, example]) => {
77
it(`renders ${name} successfully`, () => {
88
cy.mount(h(() => <example.default></example.default>)).checkA11y()
99
})
1010
})
1111
})
1212

13-
it('contains the correct role', () => {
14-
cy.mount(Examples.BaseAlert.default).get('[role=alert]').should('exist')
13+
it("contains the correct role", () => {
14+
cy.mount(Examples.BaseAlert.default).get("[role=alert]").should("exist")
1515
})
1616

17-
it('renders its children', () => {
17+
it("renders its children", () => {
1818
cy.mount(
1919
h(() => (
2020
<CAlert data-testid="alert" variant="left-accent" status="info" mb="3">
@@ -24,8 +24,8 @@ it('renders its children', () => {
2424
</CAlert>
2525
))
2626
)
27-
.get('[data-testid=alert]')
28-
.should('contain', 'Info alert')
29-
.and('contain', 'Something just happened')
30-
.and('descendants', 'svg')
27+
.get("[data-testid=alert]")
28+
.should("contain", "Info alert")
29+
.and("contain", "Something just happened")
30+
.and("descendants", "svg")
3131
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as SimpleBreadcrumb from './simple-breadcrumb.vue'
1+
export * as SimpleBreadcrumb from "./simple-breadcrumb.vue"

packages/c-breadcrumb/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './src'
1+
export * from "./src"

0 commit comments

Comments
 (0)