components#User TypeScript Examples

The following examples show how to use components#User. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.test.tsx    From geist-ui with MIT License 6 votes vote down vote up
describe(' User', () => {
  it('should render correctly', () => {
    const wrapper = mount(<User name="witt" />)
    expect(() => wrapper.unmount()).not.toThrow()
  })

  it('should support image and text', () => {
    const wrapper = render(
      <div>
        <User name="witt" text="witt" />
        <User name="witt" src="https://unix.bio/assets/avatar.png" />
      </div>,
    )
    expect(wrapper).toMatchSnapshot()
  })

  it('should render description correctly', () => {
    const wrapper = mount(<User name="witt">description</User>)
    expect(wrapper.text().toLowerCase()).toContain('description')
  })

  it('should render link on user.link', () => {
    const wrapper = mount(
      <User name="witt">
        <User.Link href="https://twitter.com/echo_witt">twitter</User.Link>
      </User>,
    )
    const link = wrapper.find('a')
    expect(link.length).not.toBe(0)
  })

  it('should pass alt attribute', () => {
    const wrapper = mount(
      <User name="witt" src="https://unix.bio/assets/avatar.png" altText="witt" />,
    )
    expect(wrapper.find('img').prop('alt')).toEqual('witt')
  })
})