diff --git a/pages/template/calendar/calendar.test.js b/pages/template/calendar/calendar.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8b7993cae8ebcebf5451635fcde3265499ca9f94 --- /dev/null +++ b/pages/template/calendar/calendar.test.js @@ -0,0 +1,13 @@ +const PAGE_PATH = '/pages/template/calendar/calendar' + +describe('calendar', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + }) + it('width', async () => { + const pageData = await page.data() + expect(pageData.testWidth > 0).toBe(true) + }) +}) diff --git a/pages/template/calendar/calendar.uvue b/pages/template/calendar/calendar.uvue index 09e999ea05d4fdf92c0b4415387e2d366f6c206e..e5e3ab1f5bb60d1198bfa905d8be598b51e3382c 100644 --- a/pages/template/calendar/calendar.uvue +++ b/pages/template/calendar/calendar.uvue @@ -39,7 +39,8 @@ export default { lunar: '', disabled: false, is_today: false - } as DateType + } as DateType, + testWidth: 0 } }, computed: { @@ -65,6 +66,10 @@ export default { // 绘制日历头部 this.drawHeader() this.drawWeek(this.weeks, '') + + // 仅自动化测试 + const header = this.$refs['draw-header'] as UniElement + this.testWidth = header.getBoundingClientRect().width; }, methods: {