From 0824cf91eaba3a2ca3552bead10d796481f181ac Mon Sep 17 00:00:00 2001 From: duqingquan Date: Sat, 16 Sep 2023 20:54:10 +0800 Subject: [PATCH] add encodeURI test case --- uni_modules/uts-tests/utssdk/KeyWord.uts | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/KeyWord.uts b/uni_modules/uts-tests/utssdk/KeyWord.uts index ec76f32..cf46ac1 100644 --- a/uni_modules/uts-tests/utssdk/KeyWord.uts +++ b/uni_modules/uts-tests/utssdk/KeyWord.uts @@ -7,6 +7,36 @@ class User{ export function testKeyWord(): Result { return describe("KeyWord", () => { + + test('encodeURI', () => { + expect(encodeURI("你好")).toEqual('%E4%BD%A0%E5%A5%BD') + expect(encodeURI("你好+22")).toEqual('%E4%BD%A0%E5%A5%BD+22') + expect(encodeURI("你;/=好+22")).toEqual('%E4%BD%A0;/=%E5%A5%BD+22') + expect(encodeURI("https://demo.dcloud.net.cn/mock/最新/12")).toEqual('https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12') + }) + + test('decodeURI', () => { + expect(decodeURI('%E4%BD%A0%E5%A5%BD')).toEqual('你好') + expect(decodeURI("%E4%BD%A0%E5%A5%BD+22")).toEqual('你好+22') + expect(decodeURI("%E4%BD%A0;/=%E5%A5%BD+22")).toEqual('你;/=好+22') + expect(decodeURI("https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12")).toEqual('https://demo.dcloud.net.cn/mock/最新/12') + }) + + test('encodeURIComponent', () => { + expect(encodeURIComponent("你好")).toEqual('%E4%BD%A0%E5%A5%BD') + expect(encodeURIComponent("你好+22")).toEqual('%E4%BD%A0%E5%A5%BD%2B22') + expect(encodeURIComponent("你;/=好+22")).toEqual('%E4%BD%A0%3B%2F%3D%E5%A5%BD%2B22') + expect(encodeURIComponent("https://demo.dcloud.net.cn/mock/最新/12")).toEqual('https%3A%2F%2Fdemo.dcloud.net.cn%2Fmock%2F%E6%9C%80%E6%96%B0%2F12') + }) + + test('decodeURIComponent', () => { + expect(decodeURIComponent('%E4%BD%A0%E5%A5%BD')).toEqual('你好') + expect(decodeURIComponent('%E4%BD%A0%E5%A5%BD%2B22')).toEqual('你好+22') + expect(decodeURIComponent('%E4%BD%A0%3B%2F%3D%E5%A5%BD%2B22')).toEqual('你;/=好+22') + expect(decodeURIComponent("https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12")).toEqual('https://demo.dcloud.net.cn/mock/最新/12') + }) + + test('new', () => { let new1 = new User() // expect(JSON.stringify(new1)).toEqual('{"age":0,"name":""}') -- GitLab