fix: localize API error messages
Build and publish Docker images / Build and publish images (push) Successful in 2m35s
Build and publish Docker images / Build and publish images (push) Successful in 2m35s
This commit is contained in:
@@ -35,7 +35,31 @@ describe('#parseAPIErrorResponse', () => {
|
||||
).toBe('Error Message [error]');
|
||||
|
||||
expect(parseAPIErrorResponse('Error: 422 Failed')).toBe(
|
||||
'Request failed. Please try again.'
|
||||
'提交的信息有误,请检查后重试。'
|
||||
);
|
||||
expect(
|
||||
parseAPIErrorResponse(new Error('Request failed with status code 401'))
|
||||
).toBe('身份验证失败,请重新登录。');
|
||||
expect(
|
||||
parseAPIErrorResponse({
|
||||
response: { status: 401, data: { error: 'invalid email or password' } },
|
||||
})
|
||||
).toBe('邮箱或密码错误,请重试。');
|
||||
expect(
|
||||
parseAPIErrorResponse({
|
||||
response: {
|
||||
status: 403,
|
||||
data: { error: 'administrator role required' },
|
||||
},
|
||||
})
|
||||
).toBe('需要管理员权限才能执行此操作。');
|
||||
expect(
|
||||
parseAPIErrorResponse({
|
||||
response: { status: 500, data: { error: 'database error' } },
|
||||
})
|
||||
).toBe('服务器发生错误,请稍后再试。');
|
||||
expect(parseAPIErrorResponse(new Error('Network Error'))).toBe(
|
||||
'网络连接失败,请检查网络后重试。'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user