Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit d130633

Browse files
committed
test(form-control): apply tests
1 parent dfa5f55 commit d130633

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/c-form-control/tests/c-form-control.cy.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
useFormControl,
1111
} from "../src"
1212
import * as Examples from "../examples"
13-
import { CInput } from "@chakra-ui/c-input"
13+
import { CInput } from "../../c-input"
1414

1515
describe("FormControl Examples", () => {
1616
Object.entries(Examples).map(([name, example]) => {
@@ -25,7 +25,7 @@ const render = (props: any = {}) => {
2525
return h(() => (
2626
<CFormControl id="name" {...props}>
2727
<CFormLabel>Name</CFormLabel>
28-
<CInput placeholder="Name" />
28+
<CInput id="name" placeholder="Name" />
2929
<CFormHelperText>Enter your name please!</CFormHelperText>
3030
<CFormErrorMessage>Your name is invalid</CFormErrorMessage>
3131
</CFormControl>
@@ -51,7 +51,7 @@ describe("<CFormControl />", () => {
5151
return h(() => (
5252
<CFormControl id="name">
5353
<CFormLabel>Name</CFormLabel>
54-
<CInput placeholder="Name" />
54+
<CInput id="name" placeholder="Name" />
5555
<CFormHelperText>Enter your name please!</CFormHelperText>
5656
<CFormErrorMessage data-testid="message">
5757
<CFormErrorIcon data-testid="icon" />
@@ -69,7 +69,7 @@ describe("<CFormControl />", () => {
6969
return h(() => (
7070
<CFormControl id="other-name">
7171
<CFormLabel>Name</CFormLabel>
72-
<CInput placeholder="Name" />
72+
<CInput id="other-name" placeholder="Name" />
7373
<CFormHelperText>Enter your name please!</CFormHelperText>
7474
<CFormErrorMessage>Your name is invalid</CFormErrorMessage>
7575
</CFormControl>
@@ -92,6 +92,7 @@ describe("<CFormControl />", () => {
9292
<CFormControl id="other-name">
9393
<CFormLabel>Name</CFormLabel>
9494
<CInput
95+
id="other-name"
9596
placeholder="Name"
9697
data-testid="input"
9798
onFocus={onFocus}
@@ -115,12 +116,12 @@ describe("<CFormControl />", () => {
115116

116117
// Here attrsibtutes a re renderedn correctly in DOM but not in
117118
// test environment. Not sure why
118-
it.skip("has the proper aria-attibutes", () => {
119+
it("has the proper aria-attibutes", () => {
119120
cy.mount(() => {
120121
return h(() => (
121122
<CFormControl id="name">
122123
<CFormLabel> First name </CFormLabel>
123-
<CInput data-testid="input" placeholder="First Name" />
124+
<CInput id="name" data-testid="input" placeholder="First Name" />
124125
<CFormHelperText> Keep it very short and sweet! </CFormHelperText>
125126
</CFormControl>
126127
))
@@ -129,8 +130,8 @@ describe("<CFormControl />", () => {
129130
cy.get('[data-testid="input"]')
130131
.should("have.attr", "aria-describedby", "helptext-name")
131132
.should("not.have.attr", "aria-invalid")
132-
.should("not.have.attr", "aria-required")
133-
.should("not.have.attr", "aria-readonly")
133+
cy.get('[data-testid="input"]').should("not.have.attr", "aria-required")
134+
cy.get('[data-testid="input"]').should("not.have.attr", "aria-readonly")
134135
})
135136
})
136137

0 commit comments

Comments
 (0)