setup.test.js 3.4 KB
Newer Older
雪洛's avatar
雪洛 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
const PAGE_PATH = '/pages/composition/setup/setup'
describe('options setup', () => {
	let page
	beforeAll(async () => {
		page = await program.reLaunch(PAGE_PATH)
		await page.waitFor('view')
	})
	it('basic', async () => {
		const str = await page.$('#str')
		expect(await str.text()).toBe('str: default str')
		const num = await page.$('#num')
		expect(await num.text()).toBe('num: 0')
		const bool = await page.$('#bool')
		expect(await bool.text()).toBe('bool: false')

		const count = await page.$('#count')
		expect(await count.text()).toBe('count: 0')

		const objStr = await page.$('#obj-str')
		expect(await objStr.text()).toBe('obj.str: obj default str')
		const objNum = await page.$('#obj-num')
		expect(await objNum.text()).toBe('obj.num: 0')
		const objBool = await page.$('#obj-bool')
		expect(await objBool.text()).toBe('obj.bool: false')

		const propsStr = await page.$('#props-str')
		expect(await propsStr.text()).toBe('props.str: default str')
		const propsCount = await page.$('#props-count')
		expect(await propsCount.text()).toBe('props.count: 0')
		const propsObjStr = await page.$('#props-obj-str')
		expect(await propsObjStr.text()).toBe(`props.obj['str']: obj default str`)
		const propsObjNum = await page.$('#props-obj-num')
		expect(await propsObjNum.text()).toBe(`props.obj['num']: 0`)
		const propsObjBool = await page.$('#props-obj-bool')
		expect(await propsObjBool.text()).toBe(`props.obj['bool']: false`)
	})
	it('props', async () => {
		const incrementBtn = await page.$('#increment-btn')
		await incrementBtn.tap()

		const count = await page.$('#count')
		expect(await count.text()).toBe('count: 1')
		const propsCount = await page.$('#props-count')
		expect(await propsCount.text()).toBe('props.count: 1')

		const updateObjBtn = await page.$('#update-obj-btn')
		await updateObjBtn.tap()

		const objStr = await page.$('#obj-str')
		expect(await objStr.text()).toBe('obj.str: obj new str')
		const objNum = await page.$('#obj-num')
		expect(await objNum.text()).toBe('obj.num: 100')
		const objBool = await page.$('#obj-bool')
		expect(await objBool.text()).toBe('obj.bool: true')

		const propsObjStr = await page.$('#props-obj-str')
		expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str`)
		const propsObjNum = await page.$('#props-obj-num')
		expect(await propsObjNum.text()).toBe(`props.obj['num']: 100`)
		const propsObjBool = await page.$('#props-obj-bool')
		expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`)
	})
	it('context', async () => {
		// attrs
		const contextAttrsIsShow = await page.$('#context-attrs-is-show')
		expect(await contextAttrsIsShow.text()).toBe('context.attrs.isShow: true')
		// emits
		const compUpdateObjBtn = await page.$('#comp-update-obj-btn')
		await compUpdateObjBtn.tap()
		const propsObjStr = await page.$('#props-obj-str')
		expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str by comp update`)
		const propsObjNum = await page.$('#props-obj-num')
		expect(await propsObjNum.text()).toBe(`props.obj['num']: 200`)
		const propsObjBool = await page.$('#props-obj-bool')
		expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`)
		// slots
		const defaultSlotInFoo = await page.$('#default-slot-in-foo')
		expect(await defaultSlotInFoo.text()).toBe('default slot in Foo')
		const hasDefaultSlot = await page.$('#has-default-slot')
		expect(await hasDefaultSlot.text()).toBe('hasDefaultSlot: true')
	})
DCloud-WZF's avatar
DCloud-WZF 已提交
82
})