From 007ef7ba2eefe574f82421a0fb688582910dea03 Mon Sep 17 00:00:00 2001 From: hdx Date: Tue, 26 Sep 2023 17:06:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(page-scroll-to):=20=E6=94=BE=E5=BC=80?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/page-scroll-to/page-scroll-to.test.js | 27 ++++++++++--------- pages/API/page-scroll-to/page-scroll-to.uvue | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pages/API/page-scroll-to/page-scroll-to.test.js b/pages/API/page-scroll-to/page-scroll-to.test.js index 730fa539..5a3c1be8 100644 --- a/pages/API/page-scroll-to/page-scroll-to.test.js +++ b/pages/API/page-scroll-to/page-scroll-to.test.js @@ -6,22 +6,23 @@ describe('page-scroll-to', () => { page = await program.reLaunch(PAGE_PATH) await page.waitFor(500) }) - // TODO it('scroll-to', async () => { const btnScrollTo = await page.$('.btn-scrollTo') await btnScrollTo.tap() - await page.waitFor(50) - // const scrollTop = await page.scrollTop() - // expect(scrollTop).toBe(100) + await page.waitFor(300) + + const scrollTop = await page.scrollTop() + expect(scrollTop).toBe(100) }) - // it('scroll-to-element', async () => { - // const btnScrollTo = await page.$('.btn-scrollToElement') - // const scrollToElement = await page.$('.custom-element') + it('scroll-to-element', async () => { + const btnScrollTo = await page.$('.btn-scrollToElement') + const scrollToElement = await page.$('.custom-element') + + await btnScrollTo.tap() + await page.waitFor(300) - // await btnScrollTo.tap() - // await page.waitFor(50) - // const offset = await scrollToElement.offset() - // expect(offset.top).toBe(0) - // }) -}) \ No newline at end of file + const offset = await scrollToElement.offset() + expect(offset.top >= 1188).toBe(true) + }) +}) diff --git a/pages/API/page-scroll-to/page-scroll-to.uvue b/pages/API/page-scroll-to/page-scroll-to.uvue index 5e89de99..43b8ee32 100644 --- a/pages/API/page-scroll-to/page-scroll-to.uvue +++ b/pages/API/page-scroll-to/page-scroll-to.uvue @@ -27,7 +27,7 @@ -