Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
glassonion1 committed Jul 4, 2024
1 parent b4923a4 commit 73e51ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 18 additions & 4 deletions packages/forms/tests/LabelControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { describe, test, expect } from 'vitest'
import { render, screen } from '@testing-library/react'

import { LabelControl, Select, Input, Textarea } from '../src'
import { LabelControl, Select, Input, Textarea, FileInput } from '../src'

describe('LabelControl', () => {
test('renders LabelControl component vol1', async () => {
Expand Down Expand Up @@ -60,6 +60,9 @@ describe('LabelControl', () => {
<Input defaultValue="1" />
</LabelControl>
<LabelControl labelText="test3">
<FileInput />
</LabelControl>
<LabelControl labelText="test4">
<Textarea defaultValue="1" />
</LabelControl>
</>
Expand All @@ -75,7 +78,11 @@ describe('LabelControl', () => {
expect(text).toHaveValue('1')
expect(text).toHaveAttribute('id')

const textarea = screen.getByLabelText(/test3/)
const file = screen.getByLabelText(/test3/)
expect(file).toBeInTheDocument()
expect(file).toHaveAttribute('id')

const textarea = screen.getByLabelText(/test4/)
expect(textarea).toBeInTheDocument()
expect(textarea).toHaveValue('1')
expect(textarea).toHaveAttribute('id')
Expand All @@ -93,6 +100,9 @@ describe('LabelControl', () => {
<Input defaultValue="1" />
</LabelControl>
<LabelControl labelText="test3" htmlFor="id3">
<FileInput />
</LabelControl>
<LabelControl labelText="test4" htmlFor="id4">
<Textarea defaultValue="1" />
</LabelControl>
</>
Expand All @@ -108,9 +118,13 @@ describe('LabelControl', () => {
expect(input).toHaveValue('1')
expect(input).toHaveAttribute('id', 'id2')

const textarea = screen.getByLabelText(/test3/)
const file = screen.getByLabelText(/test3/)
expect(file).toBeInTheDocument()
expect(file).toHaveAttribute('id', 'id3')

const textarea = screen.getByLabelText(/test4/)
expect(textarea).toBeInTheDocument()
expect(textarea).toHaveValue('1')
expect(textarea).toHaveAttribute('id', 'id3')
expect(textarea).toHaveAttribute('id', 'id4')
})
})
4 changes: 2 additions & 2 deletions packages/forms/tests/Radio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ describe('should derive values from surrounding FieldsetControl', () => {

expect(elem).toBeInTheDocument()

expect(elem).toHaveAttribute('aria-describedby', 'helper-text-:r1:')
expect(elem).toHaveAttribute('aria-errormessage', 'error-message-:r1:')
expect(elem).toHaveAttribute('aria-describedby')
expect(elem).toHaveAttribute('aria-errormessage')
})

test('renders Text component vol3', async () => {
Expand Down

0 comments on commit 73e51ca

Please sign in to comment.