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

test: request增加泛型测试例

上级 88104047
...@@ -90,6 +90,10 @@ describe('ExtApi-Request', () => { ...@@ -90,6 +90,10 @@ describe('ExtApi-Request', () => {
let version = process.env.uniTestPlatformInfo let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1]) version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9 shouldTestCookie = version > 9
}
if (process.env.uniTestPlatformInfo.startsWith('IOS') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
shouldTestCookie = true
} }
if (!shouldTestCookie) { if (!shouldTestCookie) {
...@@ -113,5 +117,11 @@ describe('ExtApi-Request', () => { ...@@ -113,5 +117,11 @@ describe('ExtApi-Request', () => {
await page.waitFor(2000); await page.waitFor(2000);
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)
}) })
}); });
...@@ -68,7 +68,11 @@ ...@@ -68,7 +68,11 @@
</scroll-view> </scroll-view>
</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",
...@@ -319,7 +323,24 @@ ...@@ -319,7 +323,24 @@
this.jest_result = false; this.jest_result = false;
}, },
}); });
}, },
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.
先完成此消息的编辑!
想要评论请 注册