提交 a80e5ae8 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 优化测试例

上级 d889babf
...@@ -13,15 +13,15 @@ describe('defineProps', () => { ...@@ -13,15 +13,15 @@ describe('defineProps', () => {
expect(await arrayLiteralNum.text()).toBe('num: 0') expect(await arrayLiteralNum.text()).toBe('num: 0')
const arrayLiteralBool = await page.$('#array-literal-bool') const arrayLiteralBool = await page.$('#array-literal-bool')
expect(await arrayLiteralBool.text()).toBe('bool: false') expect(await arrayLiteralBool.text()).toBe('bool: false')
const arrayLiteralArr = await page.$('#array-literal-arr') const arrayLiteralArr = await page.$('#array-literal-arr')
expect((await arrayLiteralArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]') expect(await arrayLiteralArr.text()).toBe('arr: ["a","b","c"]')
const arrayLiteralObj = await page.$('#array-literal-obj') const arrayLiteralObj = await page.$('#array-literal-obj')
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await arrayLiteralObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}') expect(await arrayLiteralObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}')
} }
if (process.env.uniTestPlatformInfo.startsWith('web')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect((await arrayLiteralObj.text()).replaceAll('\n', '')).toBe( expect(await arrayLiteralObj.text()).toBe(
'obj: {"str": "obj str","num": 0,"arr": [1,2,3]}') 'obj: {"str": "obj str","num": 0,"arr": [1,2,3]}')
} }
...@@ -35,15 +35,15 @@ describe('defineProps', () => { ...@@ -35,15 +35,15 @@ describe('defineProps', () => {
const objectLiteralBool = await page.$('#object-literal-bool') const objectLiteralBool = await page.$('#object-literal-bool')
expect(await objectLiteralBool.text()).toBe('bool: false') expect(await objectLiteralBool.text()).toBe('bool: false')
const objectLiteralArr = await page.$('#object-literal-arr') const objectLiteralArr = await page.$('#object-literal-arr')
expect((await objectLiteralArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]') expect(await objectLiteralArr.text()).toBe('arr: ["a","b","c"]')
const objectLiteralObj = await page.$('#object-literal-obj') const objectLiteralObj = await page.$('#object-literal-obj')
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await objectLiteralObj.text()).toBe('obj: {"a":1}') expect(await objectLiteralObj.text()).toBe('obj: {"a":1}')
} }
if (process.env.uniTestPlatformInfo.startsWith('web')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect((await objectLiteralObj.text()).replaceAll('\n', '')).toBe('obj: {"a": 1}') expect(await objectLiteralObj.text()).toBe('obj: {"a": 1}')
} }
const objectLiteralFn = await page.$('#object-literal-fn') const objectLiteralFn = await page.$('#object-literal-fn')
expect(await objectLiteralFn.text()).toBe('fn: fn res') expect(await objectLiteralFn.text()).toBe('fn: fn res')
...@@ -55,14 +55,14 @@ describe('defineProps', () => { ...@@ -55,14 +55,14 @@ describe('defineProps', () => {
const typeBool = await page.$('#type-bool') const typeBool = await page.$('#type-bool')
expect(await typeBool.text()).toBe('bool: false') expect(await typeBool.text()).toBe('bool: false')
const typeArr = await page.$('#type-arr') const typeArr = await page.$('#type-arr')
expect((await typeArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]') expect(await typeArr.text()).toBe('arr: ["a","b","c"]')
const typeObj = await page.$('#type-obj') const typeObj = await page.$('#type-obj')
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await typeObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}') expect(await typeObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}')
} }
if (process.env.uniTestPlatformInfo.startsWith('web')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect((await typeObj.text()).replaceAll('\n', '')).toBe('obj: {"str": "obj str","num": 0,"arr": [1,2,3]}') expect(await typeObj.text()).toBe('obj: {"str": "obj str","num": 0,"arr": [1,2,3]}')
} }
const typeFn = await page.$('#type-fn') const typeFn = await page.$('#type-fn')
......
...@@ -14,7 +14,7 @@ describe('useSlots', () => { ...@@ -14,7 +14,7 @@ describe('useSlots', () => {
expect(await slotContent.text()).toBe('default slot msg: default msg') expect(await slotContent.text()).toBe('default slot msg: default msg')
const slotFooter = await page.$('#slot-footer') const slotFooter = await page.$('#slot-footer')
expect((await slotFooter.text()).replaceAll('\n', '')).toBe('footer slot arr: ["a","b","c"]') expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]')
const checkUseSlotsRes = await page.$('#check-use-slots-res') const checkUseSlotsRes = await page.$('#check-use-slots-res')
expect(await checkUseSlotsRes.text()).toBe('check useSlots result: false') expect(await checkUseSlotsRes.text()).toBe('check useSlots result: false')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册