提交 75c6a85f 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

test: request增加泛型测试例

上级 88104047
...@@ -92,6 +92,10 @@ describe('ExtApi-Request', () => { ...@@ -92,6 +92,10 @@ describe('ExtApi-Request', () => {
shouldTestCookie = version > 9 shouldTestCookie = version > 9
} }
if (process.env.uniTestPlatformInfo.startsWith('IOS') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
shouldTestCookie = true
}
if (!shouldTestCookie) { if (!shouldTestCookie) {
return return
} }
...@@ -114,4 +118,10 @@ describe('ExtApi-Request', () => { ...@@ -114,4 +118,10 @@ describe('ExtApi-Request', () => {
res = await page.data('jest_result'); res = await page.data('jest_result');
expect(res).toBe(true) expect(res).toBe(true)
}) })
it('Check Get With Generics', async () => {
res = await page.callMethod('jest_get_with_generics')
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true)
})
}); });
...@@ -69,6 +69,10 @@ ...@@ -69,6 +69,10 @@
</view> </view>
</template> </template>
<script> <script>
class GETDataType {
data: UTSJSONObject | null = null
}
const duration = 2000 const duration = 2000
const methodMap = { const methodMap = {
"GET": "/api/http/method/get", "GET": "/api/http/method/get",
...@@ -320,6 +324,23 @@ ...@@ -320,6 +324,23 @@
}, },
}); });
}, },
jest_get_with_generics() {
uni.request<GETDataType>({
url: this.host + (methodMap['GET'] as string),
method: "GET",
timeout: null,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: (res: RequestSuccess<GETDataType>) => {
console.log("success :", res.data?.data);
this.jest_result = true;
},
fail: () => {
this.jest_result = false;
},
});
}
} }
} }
</script> </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册