mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
test(PasswordInput): update test cases
This commit is contained in:
parent
669d2e77ae
commit
b317ac46ce
7
src/password-input/test/__snapshots__/index.spec.js.snap
Normal file
7
src/password-input/test/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`should render error info correctly 1`] = `
|
||||||
|
<div class="van-password-input__error-info">
|
||||||
|
error!
|
||||||
|
</div>
|
||||||
|
`;
|
@ -1,16 +0,0 @@
|
|||||||
import PasswordInput from '..';
|
|
||||||
import { mount } from '@vue/test-utils';
|
|
||||||
|
|
||||||
test('focus event', () => {
|
|
||||||
const focus = jest.fn();
|
|
||||||
const wrapper = mount(PasswordInput, {
|
|
||||||
context: {
|
|
||||||
on: {
|
|
||||||
focus,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
wrapper.find('.van-password-input__security').trigger('touchstart');
|
|
||||||
expect(focus).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
19
src/password-input/test/index.spec.js
Normal file
19
src/password-input/test/index.spec.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import PasswordInput from '..';
|
||||||
|
import { mount } from '@vue/test-utils';
|
||||||
|
|
||||||
|
test('should emit focus event when security is touched', () => {
|
||||||
|
const wrapper = mount(PasswordInput);
|
||||||
|
wrapper.find('.van-password-input__security').trigger('touchstart');
|
||||||
|
expect(wrapper.emitted('focus').length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render error info correctly', () => {
|
||||||
|
const wrapper = mount(PasswordInput, {
|
||||||
|
props: {
|
||||||
|
errorInfo: 'error!',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
wrapper.find('.van-password-input__error-info').html()
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user