Skip to content

Commit

Permalink
test(Textarea): add test case (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao authored Jun 1, 2023
1 parent 8679b56 commit 94eda83
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/textarea/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ describe('Textarea.vue', () => {
expect(textarea.element.hasAttribute('disabled')).toBeTruthy();
});

it(': indicator', async () => {
const maxcharacter = 20;
const wrapper = mount(<Textarea label="标题" indicator maxcharacter={maxcharacter} />);
const indicator = wrapper.find('.t-textarea__indicator');
expect(indicator.exists()).toBeTruthy();
expect(indicator.text()).toBe(`0/${maxcharacter}`);
});
});

describe(':event', () => {
it(': onBlur', async () => {
const onBlur = vi.fn();
const onFocus = vi.fn();
Expand All @@ -79,6 +89,14 @@ describe('Textarea.vue', () => {
expect(onFocus).toBeCalled();
});

it(': onCompositionend', async () => {
const onCompositionend = vi.fn();
const wrapper = mount(<Textarea label="标题" onCompositionend={onCompositionend} />);
const textarea = wrapper.find('textarea');
await textarea.trigger('compositionend');
expect(onCompositionend).toBeCalled();
});

it(': onChange ', async () => {
const data = ref('');
const value = ref('');
Expand Down

0 comments on commit 94eda83

Please sign in to comment.