From 45e8df613c02f6603486249cf433afee50026ff4 Mon Sep 17 00:00:00 2001 From: npmstudy Date: Wed, 29 Nov 2023 19:54:49 +0800 Subject: [PATCH] chore: refact --- packages/core/src/__tests__/app.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/core/src/__tests__/app.test.ts b/packages/core/src/__tests__/app.test.ts index 05e2340..f9fcdb0 100644 --- a/packages/core/src/__tests__/app.test.ts +++ b/packages/core/src/__tests__/app.test.ts @@ -24,6 +24,14 @@ describe('app', async () => { } }); + rpc.fn('com.yourcompony.a', function (a: string) { + return { a: a }; + }); + + rpc.fn('com.yourcompony.b', function (a: string) { + return `${this.path} , ${a} `; + }); + const request = supertest(rpc.callback()); it('should acess /a', async () => { @@ -47,4 +55,11 @@ describe('app', async () => { expect(res.status).toEqual(200); expect(res.body).toEqual({ a: 'hello', method: 'post' }); }); + + it('should acess com.yourcompony.b', async () => { + const res = await request.get('/api/com/yourcompony/b?$p=["hello"]'); + expect(res.type).toEqual('text/plain'); + expect(res.status).toEqual(200); + expect(res.text).toEqual('/com/yourcompony/b , hello '); + }); });