提交 e19271a2 编写于 作者: W wangjinxin613

test:调整若干示例兼容 safari

上级 87c3aee0
const PAGE_PATH = '/pages/composition-api/basic/define-props/define-props'
describe('defineProps', () => {
describe('defineProps', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -14,7 +15,7 @@ describe('defineProps', () => {
const arrayLiteralBool = await page.$('#array-literal-bool')
expect(await arrayLiteralBool.text()).toBe('bool: false')
const arrayLiteralArr = await page.$('#array-literal-arr')
expect(await arrayLiteralArr.text()).toBe('arr: ["a","b","c"]')
expect(await arrayLiteralArr.text()).toBe(isSafari ? 'arr: [ "a", "b", "c"]' : 'arr: ["a","b","c"]')
const arrayLiteralObj = await page.$('#array-literal-obj')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
......@@ -22,7 +23,7 @@ describe('defineProps', () => {
}
if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect(await arrayLiteralObj.text()).toBe(
'obj: {"str": "obj str","num": 0,"arr": [1,2,3]}')
isSafari ? 'obj: { "str": "obj str", "num": 0, "arr": [ 1, 2, 3 ]}' : 'obj: {"str": "obj str","num": 0,"arr": [1,2,3]}')
}
const arrayLiteralFn = await page.$('#array-literal-fn')
......@@ -35,14 +36,14 @@ describe('defineProps', () => {
const objectLiteralBool = await page.$('#object-literal-bool')
expect(await objectLiteralBool.text()).toBe('bool: false')
const objectLiteralArr = await page.$('#object-literal-arr')
expect(await objectLiteralArr.text()).toBe('arr: ["a","b","c"]')
expect(await objectLiteralArr.text()).toBe(isSafari ? 'arr: [ "a", "b", "c"]' : 'arr: ["a","b","c"]')
const objectLiteralObj = await page.$('#object-literal-obj')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await objectLiteralObj.text()).toBe('obj: {"a":1}')
}
if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect(await objectLiteralObj.text()).toBe('obj: {"a": 1}')
expect(await objectLiteralObj.text()).toBe(isSafari ? 'obj: { "a": 1}' : 'obj: {"a": 1}')
}
const objectLiteralFn = await page.$('#object-literal-fn')
......@@ -55,14 +56,14 @@ describe('defineProps', () => {
const typeBool = await page.$('#type-bool')
expect(await typeBool.text()).toBe('bool: false')
const typeArr = await page.$('#type-arr')
expect(await typeArr.text()).toBe('arr: ["a","b","c"]')
expect(await typeArr.text()).toBe(isSafari ? 'arr: [ "a", "b", "c"]' : 'arr: ["a","b","c"]')
const typeObj = await page.$('#type-obj')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await typeObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}')
}
if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect(await typeObj.text()).toBe('obj: {"str": "obj str","num": 0,"arr": [1,2,3]}')
expect(await typeObj.text()).toBe(isSafari ? 'obj: { "str": "obj str", "num": 0, "arr": [ 1, 2, 3 ]}' : 'obj: {"str": "obj str","num": 0,"arr": [1,2,3]}')
}
const typeFn = await page.$('#type-fn')
......
const PAGE_PATH = '/pages/composition-api/basic/define-slots/define-slots'
describe('defineSlots', () => {
describe('defineSlots', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -14,6 +15,6 @@ describe('defineSlots', () => {
expect(await slotContent.text()).toBe('default slot num: 0')
const slotFooter = await page.$('#slot-footer')
expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]')
expect(await slotFooter.text()).toBe(isSafari ? 'footer slot arr: [ "a", "b", "c"]' : 'footer slot arr: ["a","b","c"]')
})
})
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/basic/use-slots/use-slots'
describe('useSlots', () => {
describe('useSlots', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -14,7 +15,7 @@ describe('useSlots', () => {
expect(await slotContent.text()).toBe('default slot msg: default msg')
const slotFooter = await page.$('#slot-footer')
expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]')
expect(await slotFooter.text()).toBe(isSafari ? 'footer slot arr: [ "a", "b", "c"]' : 'footer slot arr: ["a","b","c"]')
const checkUseSlotsRes = await page.$('#check-use-slots-res')
expect(await checkUseSlotsRes.text()).toBe('check useSlots result: false')
......
const PAGE_PATH = '/pages/composition-api/dependency-injection/provide/provide'
describe('provide-inject-hasInjectionContext', () => {
describe('provide-inject-hasInjectionContext', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
const isWeb = process.env.uniTestPlatformInfo.startsWith('web')
let page = null
beforeAll(async () => {
......@@ -15,11 +16,11 @@ describe('provide-inject-hasInjectionContext', () => {
expect(await num.text()).toBe('num: 0')
const obj = await page.$('.obj')
expect(await obj.text()).toBe(isWeb ? 'obj: {"a": 1}' : 'obj: {"a":1}')
expect(await obj.text()).toBe(isWeb ? (isSafari ? 'obj: { "a": 1}' : 'obj: {"a": 1}') : 'obj: {"a":1}')
const arr = await page.$('.arr')
expect(await arr.text()).toBe('arr: [1,2,3]')
expect(await arr.text()).toBe(isSafari ? 'arr: [ 1, 2, 3]' : 'arr: [1,2,3]')
const fn = await page.$('.fn')
expect(await fn.text()).toBe('fn: hello')
......
const PAGE_PATH = '/pages/composition-api/reactivity/computed/computed'
describe('computed', () => {
describe('computed', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -13,7 +14,7 @@ describe('computed', () => {
expect(await doubleCount.text()).toBe('computed double count: 0')
const objArr = await page.$('#obj-arr')
expect(await objArr.text()).toBe('obj.arr: [1,2,3]')
expect(await objArr.text()).toBe(isSafari ? 'obj.arr: [ 1, 2, 3]' : 'obj.arr: [1,2,3]')
const objArrLen = await page.$('#obj-arr-len')
expect(await objArrLen.text()).toBe('computed obj.arr.length: 3')
......@@ -22,7 +23,7 @@ describe('computed', () => {
expect(await count.text()).toBe('count: 1')
expect(await doubleCount.text()).toBe('computed double count: 2')
expect(await objArr.text()).toBe('obj.arr: [1,2,3,4]')
expect(await objArr.text()).toBe(isSafari ? 'obj.arr: [ 1, 2, 3, 4]' : 'obj.arr: [1,2,3,4]')
expect(await objArrLen.text()).toBe('computed obj.arr.length: 4')
})
......
const PAGE_PATH = '/pages/composition-api/reactivity/reactive/reactive'
describe('reactive', () => {
describe('reactive', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -17,7 +18,7 @@ describe('reactive', () => {
expect(await objNum.text()).toBe('obj.num: 0')
const objArr = await page.$('#obj-arr')
expect(await objArr.text()).toBe('obj.arr: ["a","b","c"]')
expect(await objArr.text()).toBe(isSafari ? 'obj.arr: [ "a", "b", "c"]' : 'obj.arr: ["a","b","c"]')
const updateBtn = await page.$('.update-btn')
await updateBtn.tap()
......@@ -25,6 +26,6 @@ describe('reactive', () => {
expect(await count.text()).toBe('count: 2')
expect(await objStr.text()).toBe('obj.str: new str')
expect(await objNum.text()).toBe('obj.num: 2')
expect(await objArr.text()).toBe('obj.arr: ["a","b","c","d"]')
expect(await objArr.text()).toBe(isSafari ? 'obj.arr: [ "a", "b", "c", "d"]' : 'obj.arr: ["a","b","c","d"]')
})
})
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly'
describe('ref', () => {
describe('ref', () => {
const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -12,33 +13,33 @@ describe('ref', () => {
const dataNum = await page.$('#data-num')
expect(await dataNum.text()).toBe('data.num: 0')
const dataArr = await page.$('#data-arr')
expect(await dataArr.text()).toBe('data.arr: ["a","b","c"]')
expect(await dataArr.text()).toBe(isSafari ? 'data.arr: [ "a", "b", "c"]' : 'data.arr: ["a","b","c"]')
const readonlyDataStr = await page.$('#readonly-data-str')
expect(await readonlyDataStr.text()).toBe('readonly data.str: default str')
const readonlyDataNum = await page.$('#readonly-data-num')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 0')
const readonlyDataArr = await page.$('#readonly-data-arr')
expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c"]')
expect(await readonlyDataArr.text()).toBe(isSafari ? 'readonly data.arr: [ "a", "b", "c"]' : 'readonly data.arr: ["a","b","c"]')
const updateDataBtn = await page.$('#update-data-btn')
await updateDataBtn.tap()
expect(await dataStr.text()).toBe('data.str: new str')
expect(await dataNum.text()).toBe('data.num: 1')
expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
expect(await dataArr.text()).toBe(isSafari ? 'data.arr: [ "a", "b", "c", "d"]' : 'data.arr: ["a","b","c","d"]')
expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
expect(await readonlyDataArr.text()).toBe(isSafari ? 'readonly data.arr: [ "a", "b", "c", "d"]' : 'readonly data.arr: ["a","b","c","d"]')
const updateReadonlyDataBtn = await page.$('#update-readonly-data-btn')
await updateReadonlyDataBtn.tap()
expect(await dataStr.text()).toBe('data.str: new str')
expect(await dataNum.text()).toBe('data.num: 1')
expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
expect(await dataArr.text()).toBe(isSafari ? 'data.arr: [ "a", "b", "c", "d"]' : 'data.arr: ["a","b","c","d"]')
expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
expect(await readonlyDataArr.text()).toBe(isSafari ? 'readonly data.arr: [ "a", "b", "c", "d"]' : 'readonly data.arr: ["a","b","c","d"]')
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册