generated from arvinxx/monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
11 changes: 8 additions & 3 deletions
11
packages/float-label-input/tests/__snapshots__/index.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
|
||
import FloatLabelInput from '@arvinxu/float-label-input'; | ||
|
||
test('FloatLabelInput', () => { | ||
const { container } = render(<FloatLabelInput label={'test'} />); | ||
expect(container).toMatchSnapshot(); | ||
describe('FloatLabelInput', () => { | ||
it('正常渲染', () => { | ||
const { container } = render(<FloatLabelInput label={'test'} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('受控组件', () => { | ||
// const { container } = render(<FloatLabelInput label={'test'} />); | ||
}); | ||
|
||
it('focus 向上移动; blur 返回', () => { | ||
const { queryByTestId } = render(<FloatLabelInput label={'test'} />); | ||
|
||
const input = queryByTestId('input'); | ||
const label = queryByTestId('label'); | ||
|
||
expect(label.style.transform).toBe(''); | ||
fireEvent.focus(input); | ||
expect(label.style.transform).toBe('translateY(-28px)'); | ||
fireEvent.blur(input); | ||
expect(label.style.transform).toBe(''); | ||
}); | ||
|
||
it('可输入外部高度', () => { | ||
// const { queryByTestId } = render( | ||
// <FloatLabelInput label={'test'} style={{ height: 40 }} />, | ||
// ); | ||
// const input = queryByTestId('input'); | ||
// fireEvent.focus(input); | ||
// const label = queryByTestId('label'); | ||
// debug(label); | ||
// expect(label.style.transform).toBe('translateY(-32px)'); | ||
}); | ||
}); |