Skip to content

Commit 6acefb3

Browse files
committed
Add tests
1 parent 2ec36e8 commit 6acefb3

File tree

7 files changed

+1174
-342
lines changed

7 files changed

+1174
-342
lines changed

src/TextInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputInternalProps>(
5656
hasIcon={!!IconComponent || !!(LeadingIconComponent || TrailingIconComponent)}
5757
sx={sxProp}
5858
theme={theme}
59+
size={sizeProp}
5960
width={widthProp}
6061
minWidth={minWidthProp}
6162
maxWidth={maxWidthProp}

src/_TextInputWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const TextInputWrapper = styled.span<StyledWrapperProps>`
5858
line-height: 20px;
5959
color: ${get('colors.fg.default')};
6060
vertical-align: middle;
61-
background-color: ${get('colors.input.bg')};
61+
background-color: ${get('colors.canvas.default')};
6262
background-repeat: no-repeat; // Repeat and position set for form states (success, error, etc)
6363
background-position: right 8px center; // For form validation. This keeps images 8px from right and centered vertically.
6464
border: 1px solid ${get('colors.border.default')};

src/__tests__/TextInput.test.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {render, mount, behavesAsComponent, checkExports} from '../utils/testing'
44
import {render as HTMLRender, cleanup} from '@testing-library/react'
55
import {axe, toHaveNoViolations} from 'jest-axe'
66
import 'babel-polyfill'
7+
import {SearchIcon} from '@primer/octicons-react'
78
expect.extend(toHaveNoViolations)
89

910
describe('TextInput', () => {
@@ -25,17 +26,41 @@ describe('TextInput', () => {
2526
})
2627

2728
it('renders small', () => {
28-
expect(render(<TextInput name="zipcode" variant="small" />)).toMatchSnapshot()
29+
expect(render(<TextInput name="zipcode" size="small" />)).toMatchSnapshot()
2930
})
3031

3132
it('renders large', () => {
32-
expect(render(<TextInput name="zipcode" variant="large" />)).toMatchSnapshot()
33+
expect(render(<TextInput name="zipcode" size="large" />)).toMatchSnapshot()
3334
})
3435

3536
it('renders block', () => {
3637
expect(render(<TextInput name="zipcode" block />)).toMatchSnapshot()
3738
})
3839

40+
it('renders warning', () => {
41+
expect(render(<TextInput name="zipcode" status="warning" />)).toMatchSnapshot()
42+
})
43+
44+
it('renders error', () => {
45+
expect(render(<TextInput name="zipcode" status="error" />)).toMatchSnapshot()
46+
})
47+
48+
it('renders contrast', () => {
49+
expect(render(<TextInput name="zipcode" status="contrast" />)).toMatchSnapshot()
50+
})
51+
52+
it('renders placeholder', () => {
53+
expect(render(<TextInput name="zipcode" placeholder={'560076'} />)).toMatchSnapshot()
54+
})
55+
56+
it('renders leadingIcon', () => {
57+
expect(render(<TextInput name="search" placeholder={'Search'} leadingIcon={SearchIcon} />)).toMatchSnapshot()
58+
})
59+
60+
it('renders trailingIcon', () => {
61+
expect(render(<TextInput name="search" placeholder={'Search'} trailingIcon={SearchIcon} />)).toMatchSnapshot()
62+
})
63+
3964
it('should call onChange prop with input value', () => {
4065
const onChangeMock = jest.fn()
4166
const component = mount(<TextInput onChange={onChangeMock} value="test" />)

0 commit comments

Comments
 (0)