axios-miniprogram/__tests__/adaptive.spec.ts

29 lines
453 B
TypeScript
Raw Normal View History

2020-04-20 22:33:15 +08:00
import adaptive from '../src/adaptive';
declare global {
namespace NodeJS {
interface Global {
wx: any;
}
}
}
describe('测试 src/adaptive.ts', () => {
it('适配成功', () => {
const request = jest.fn();
global.wx = {
request,
};
const adapter = adaptive();
expect(adapter).toBe(request);
});
it('适配失败', () => {
2020-07-23 10:52:25 +08:00
global.wx = void 0;
2020-04-20 22:33:15 +08:00
expect(adaptive()).toBeUndefined();
});
});