lint
This commit is contained in:
977 files changed
+198426
-158324
No files matched your search
@@ -3,29 +3,29 @@ import { describe, expect, it } from 'vitest';
|
||||
import { OtpInput } from '../src/components/interior/otp-input';
|
||||
|
||||
describe('OtpInput official error/hint contract', () => {
|
||||
it('shows the hint while error is false', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<OtpInput
|
||||
label="验证码"
|
||||
hint="可以把完整验证码粘贴到任意一格。"
|
||||
error={false}
|
||||
errorMessage="验证码不正确,改错的那一位即可。"
|
||||
/>,
|
||||
);
|
||||
expect(markup).toContain('可以把完整验证码粘贴到任意一格。');
|
||||
expect(markup).not.toContain('验证码不正确,改错的那一位即可。');
|
||||
});
|
||||
it('shows the hint while error is false', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<OtpInput
|
||||
label="验证码"
|
||||
hint="可以把完整验证码粘贴到任意一格。"
|
||||
error={false}
|
||||
errorMessage="验证码不正确,改错的那一位即可。"
|
||||
/>,
|
||||
);
|
||||
expect(markup).toContain('可以把完整验证码粘贴到任意一格。');
|
||||
expect(markup).not.toContain('验证码不正确,改错的那一位即可。');
|
||||
});
|
||||
|
||||
it('swaps to the error message when error is true', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<OtpInput
|
||||
label="验证码"
|
||||
hint="可以把完整验证码粘贴到任意一格。"
|
||||
error
|
||||
errorMessage="验证码不正确,改错的那一位即可。"
|
||||
/>,
|
||||
);
|
||||
expect(markup).toContain('验证码不正确,改错的那一位即可。');
|
||||
expect(markup).toContain('aria-invalid="true"');
|
||||
});
|
||||
it('swaps to the error message when error is true', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<OtpInput
|
||||
label="验证码"
|
||||
hint="可以把完整验证码粘贴到任意一格。"
|
||||
error
|
||||
errorMessage="验证码不正确,改错的那一位即可。"
|
||||
/>,
|
||||
);
|
||||
expect(markup).toContain('验证码不正确,改错的那一位即可。');
|
||||
expect(markup).toContain('aria-invalid="true"');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user