Skip to content

Commit

Permalink
test: fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Aug 14, 2024
1 parent 55c3d90 commit bfa41b8
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions tests/validate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ describe('Form.Validate', () => {
<InfoField name="noop" rules={[{ required: true, message: 'noop' }]}>
<Input />
</InfoField>
</Form>,
</Form>
);

const { container, rerender } = render(
Expand Down Expand Up @@ -1086,18 +1086,13 @@ describe('Form.Validate', () => {
const { container } = render(
<Form>
<InfoField
messageVariables={{
name: 'bamboo',
}}
name="test"
rules={[
{
validator: async (_, value) => {
if (value !== 'bamboo') {
return Promise.reject(new Error('should be ${name}!'));
}
return '';
},
messageVariables: {
name: 'bamboo',
},
validator: () => Promise.reject(new Error('\\${name} should be ${name}!')),
},
]}
>
Expand All @@ -1108,14 +1103,6 @@ describe('Form.Validate', () => {

// Wrong value
await changeValue(getInput(container), 'light');
matchError(container, 'should be bamboo!');

// Correct value
await changeValue(getInput(container), 'bamboo');
matchError(container, false);

// Escaped variable
await changeValue(getInput(container), 'should be ${name}!');
matchError(container, 'should be ${name}!');
matchError(container, '${name} should be bamboo!');
});
});

0 comments on commit bfa41b8

Please sign in to comment.