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

test: request增加泛型测试例

上级 88104047
......@@ -90,6 +90,10 @@ describe('ExtApi-Request', () => {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
}
if (process.env.uniTestPlatformInfo.startsWith('IOS') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
shouldTestCookie = true
}
if (!shouldTestCookie) {
......@@ -113,5 +117,11 @@ describe('ExtApi-Request', () => {
await page.waitFor(2000);
res = await page.data('jest_result');
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 @@
</scroll-view>
</view>
</template>
<script>
<script>
class GETDataType {
data: UTSJSONObject | null = null
}
const duration = 2000
const methodMap = {
"GET": "/api/http/method/get",
......@@ -319,7 +323,24 @@
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>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册