mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-25 12:55:36 +08:00
27 lines
888 B
TypeScript
27 lines
888 B
TypeScript
import React from 'react'
|
|
import { mount } from 'enzyme'
|
|
import { Input } from 'components'
|
|
import { nativeEvent } from 'tests/utils'
|
|
|
|
describe('InputPassword', () => {
|
|
it('should render correctly', () => {
|
|
const wrapper = mount(<Input.Password />)
|
|
const el = wrapper.find('input').getDOMNode() as HTMLInputElement
|
|
expect(el.type).toEqual('password')
|
|
expect(wrapper.html()).toMatchSnapshot()
|
|
expect(() => wrapper.unmount()).not.toThrow()
|
|
})
|
|
|
|
it('should toggle input type', () => {
|
|
const wrapper = mount(<Input.Password />)
|
|
wrapper.find('.input-icon').simulate('click', nativeEvent)
|
|
const el = wrapper.find('input').getDOMNode() as HTMLInputElement
|
|
expect(el.type).toEqual('text')
|
|
})
|
|
|
|
it('should hide toggle icon', () => {
|
|
const wrapper = mount(<Input.Password hideToggle />)
|
|
expect(wrapper.find('.input-icon').length).toBe(0)
|
|
})
|
|
})
|