Skip to content

Conversation

haworku
Copy link
Contributor

@haworku haworku commented Aug 5, 2020

Summary

Add CharacterCount based on uwds spec . See also discussion in #169

Related Issues or PRs

closes #169

How To Test

Check Forms/ Character Count in Storybook

@haworku haworku added the type: feature New feature or request label Aug 5, 2020
@haworku haworku requested a review from jim August 5, 2020 16:43
@haworku haworku changed the title feat(CharacterCount): New component CharacterCount feat(CharacterCount): Add new component CharacterCount Aug 5, 2020
@haworku haworku requested a review from ahobson August 7, 2020 13:46
@ahobson
Copy link
Contributor

ahobson commented Aug 7, 2020

  • write a test that textRef prop behaves as expected. Having some trouble testing this (specifically creating a ref that our current typescript definitions like). Realized this is first time we are testing the ref prop on a input so our types could be wrong.

Is this testing what you had in mind?

    it('supports inputRef', () => {
      const tRef = React.createRef<HTMLTextAreaElement>()
      const { queryByTestId } = render(
        <CharacterCount
          id="character-count"
          name="character-count"
          maxLength={10}
          isTextArea
          inputRef={tRef}
        />
      )
      expect(queryByTestId('textarea')).toBe(tRef.current)
    })

@haworku
Copy link
Contributor Author

haworku commented Aug 7, 2020

  • write a test that textRef prop behaves as expected. Having some trouble testing this (specifically creating a ref that our current typescript definitions like). Realized this is first time we are testing the ref prop on a input so our types could be wrong.

Is this testing what you had in mind?

    it('supports inputRef', () => {
      const tRef = React.createRef<HTMLTextAreaElement>()
      const { queryByTestId } = render(
        <CharacterCount
          id="character-count"
          name="character-count"
          maxLength={10}
          isTextArea
          inputRef={tRef}
        />
      )
      expect(queryByTestId('textarea')).toBe(tRef.current)
    })

@ahobson Yes, something like that. Was using useRef. However, either way I can't get those tests actually passing - get typescript errors. In the case of this test Type '{ id: string; name: string; defaultValue: string; maxLength: number; ref: RefObject<HTMLInputElement>; }' is not assignable to type 'ClassAttributes<HTMLTextAreaElement>'. Let's pair on this.

Copy link
Contributor

@ahobson ahobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@haworku haworku merged commit cc12034 into main Aug 10, 2020
@haworku haworku deleted the hw-character-count-169 branch August 10, 2020 14:59
@haworku haworku mentioned this pull request Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New component: Forms / Character count
3 participants