24 lines
749 B
TypeScript
24 lines
749 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { mapAliyunException } from '../../../services/auth/aliyun-sms.js';
|
|
|
|
describe('aliyun-sms', () => {
|
|
it('maps Aliyun validate failure during verification to invalid code error', () => {
|
|
const error = {
|
|
name: 'ClientError',
|
|
code: 'isv.ValidateFail',
|
|
message: 'isv.ValidateFail: code: 400, 验证失败 request id: request-id',
|
|
data: {
|
|
Code: 'isv.ValidateFail',
|
|
Message: '验证失败',
|
|
},
|
|
statusCode: 400,
|
|
};
|
|
|
|
const mapped = mapAliyunException(error, 'verify');
|
|
|
|
expect(mapped.statusCode).toBe(401);
|
|
expect(mapped.code).toBe('INVALID_VERIFY_CODE');
|
|
expect(mapped.message).toBe('验证码无效或已过期');
|
|
});
|
|
});
|