feat: 添加query功能

This commit is contained in:
2024-09-08 04:32:41 +08:00
parent 443a41110a
commit 360f6ba180
24 changed files with 6228 additions and 48 deletions

12
test/adapter.ts Normal file
View File

@@ -0,0 +1,12 @@
import { adapter } from '../src/adapter';
const hostname = 'localhost:3002';
describe('Adapter', () => {
// 编写一个测试用例
// yarn test --testNamePattern='Adapter'
test('Adapter:First', () => {
adapter({ url: hostname + '/api/router' }).then((res) => {
expect(res).toEqual({ id: 1 });
});
});
});

7
test/hello.test.ts Normal file
View File

@@ -0,0 +1,7 @@
describe('Hello', () => {
// 编写一个测试用例
// yarn test --testNamePattern='Hello'
test('Hello World', () => {
console.log('Hello World');
});
});

17
test/node-adapter.ts Normal file
View File

@@ -0,0 +1,17 @@
import { nodeAdapter } from "../src/node-adapter";
// tsx test/node-adapter.ts
const main = async () => {
const res = await nodeAdapter({
url: 'http://127.0.0.1/api/router',
headers: {
'Content-Type': 'application/json',
},
body: {
path: 'demo',
key: '1',
},
});
console.log(res);
};
main();

View File

@@ -2,8 +2,24 @@ import { Query } from './../src/index';
const query = new Query({ url: '/api/router' });
describe('Query', () => {
// 编写一个测试用例
// yarn test --testNamePattern='Query'
test('Query:First', async () => {
console.log('Query');
});
});
// test('query', async () => {
// query.get({ id: 1 }).then((res) => {
// expect(res).toEqual({ id: 1 });
// });
// }
// describe('Hello', () => {
// // 编写一个测试用例
// // yarn test --testNamePattern='Hello'
// test('Hello World', () => {
// console.log('Hello World');
// });
// });