diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js index d16c75a23fcfb80571a41b5679169b5413977046..1694c811a1104dc9dfafe8ecab95930329c6a0ef 100644 --- a/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js +++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js @@ -16,11 +16,16 @@ describe("setNavigationBarColor", () => { expect(lifeCycleNum).toBe(originLifeCycleNum); }); - it("setNavigationBarTitle", async () => { - await page.callMethod("setNavigationBarTitle"); + it("setNavigationBarNewTitle", async () => { + await page.callMethod("setNavigationBarNewTitle"); const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); const lifeCycleNum = await page.callMethod("getLifeCycleNum"); expect(lifeCycleNum - originLifeCycleNum).toBe(2); }); + it("setNavigationBarLongTitle", async () => { + await page.callMethod("setNavigationBarLongTitle"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); }); diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue index 5f917f3190b5911750b37f11499a7ee2b8c3ac69..00f2e8e11c09fcfcce3ac13a134db60628b5a4cc 100644 --- a/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue +++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue @@ -2,8 +2,11 @@ - + @@ -15,11 +18,12 @@ import { state, setLifeCycleNum } from '@/store/index.uts' export default { data(){ return { - newTitle: 'new title' + newTitle: 'new title', + longTitle: 'long title long title long title long title long title long title long title long title long title long title' } }, methods: { - setNavigationBarTitle() { + setNavigationBarNewTitle() { uni.setNavigationBarTitle({ title: this.newTitle, success() { @@ -27,7 +31,7 @@ export default { this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarTitle success') + console.log('setNavigationBarTitle fail') this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { @@ -36,6 +40,20 @@ export default { } }) }, + setNavigationBarLongTitle() { + uni.setNavigationBarTitle({ + title: this.longTitle, + success() { + console.log('setNavigationBarTitle success') + }, + fail() { + console.log('setNavigationBarTitle fail') + }, + complete() { + console.log('setNavigationBarTitle complete') + } + }) + }, // 自动化测试 getLifeCycleNum(): number { return state.lifeCycleNum