axios-miniprogram/test/helpers/error.test.ts

20 lines
609 B
TypeScript
Raw Normal View History

2023-03-28 21:32:54 +08:00
import { describe, test, expect } from 'vitest';
2023-03-29 22:23:36 +08:00
import { assert, throwError } from 'src/helpers/error';
2023-03-28 21:32:54 +08:00
describe('测试 src/helpers/error.ts', () => {
test('第一个参数为 true 时应该无事发生', () => {
expect(assert(true, '')).toBeUndefined();
});
test('第一个参数为 false 时应该抛出异常', () => {
expect(() => assert(false, '')).toThrowError();
});
test('应该抛出异常', () => {
expect(() => throwError('')).toThrowError('[axios-miniprogram]: ');
expect(() => throwError('error')).toThrowError(
'[axios-miniprogram]: error',
);
});
});