diff --git a/App.uvue b/App.uvue index 91dd5ed97f99adcab5e5d8d5743862765a8fd378..ad6333956e97404488cfa4134df6caa7956cd3c8 100644 --- a/App.uvue +++ b/App.uvue @@ -2,11 +2,23 @@ import { state, setLifeCycleNum } from '@/store/index.uts' let firstBackTime = 0 - export default { - globalData: { - str: 'global data str', - num: 123, - bool: true, + export default { + globalData: { + str: 'default globalData str', + num: 0, + bool: false, + obj: { + str: 'default globalData obj str', + num: 0, + bool: false, + }, + null: null as string | null, + arr: [] as number[], + set: new Set(), + map: new Map(), + func: (): string => { + return 'globalData func' + } }, onLaunch: function () { // 自动化测试 @@ -67,4 +79,4 @@ \ No newline at end of file + diff --git a/pages/API/get-app/get-app.test.js b/pages/API/get-app/get-app.test.js index 4d229d7e50354838641cda19b375b92ce2a96666..8d01b33e0f1d45f635c7977c152bce6c35ea1a20 100644 --- a/pages/API/get-app/get-app.test.js +++ b/pages/API/get-app/get-app.test.js @@ -9,15 +9,24 @@ describe('getApp', () => { it('globalData', async () => { await page.callMethod('getGlobalData') let data = await page.data() - expect(data.globalDataStr).toBe('global data str') - expect(data.globalDataNum).toBe(123) - expect(data.globalDataBool).toBe(true) + expect(data.originGlobalData.str).toBe('default globalData str') + expect(data.originGlobalData.num).toBe(0) + expect(data.originGlobalData.bool).toBe(false) + expect(data.originGlobalData.obj).toEqual({bool: false, num: 0, str: 'default globalData obj str'}) + expect(data.originGlobalData.arr).toEqual([]) + expect(data.originGlobalData.set).toEqual([]) + expect(data.originGlobalData.map).toEqual({}) + expect(data.originGlobalDataFuncRes).toBe('globalData func') await page.callMethod('setGlobalData') - await page.callMethod('getGlobalData') data = await page.data() - expect(data.globalDataStr).toBe('new global data str') - expect(data.globalDataNum).toBe(456) - expect(data.globalDataBool).toBe(false) + expect(data.newGlobalData.str).toBe('new globalData str') + expect(data.newGlobalData.num).toBe(100) + expect(data.newGlobalData.bool).toBe(true) + expect(data.newGlobalData.obj).toEqual({bool: true, num: 200, str: 'new globalData obj str'}) + expect(data.newGlobalData.arr).toEqual([1,2,3]) + expect(data.newGlobalData.set).toEqual(['a', 'b', 'c']) + expect(data.newGlobalData.map).toEqual({'a': 1, 'b': 2, 'c': 3}) + expect(data.newGlobalDataFuncRes).toBe('new globalData func') }) it('method', async () => { const oldLifeCycleNum = await page.data('lifeCycleNum') diff --git a/pages/API/get-app/get-app.uvue b/pages/API/get-app/get-app.uvue index 3b8365dbb86d7db0b9a0d78837cb2aa0c31015f0..f3bc1dd756e5aacf9c92181f852e023d9beeecb7 100644 --- a/pages/API/get-app/get-app.uvue +++ b/pages/API/get-app/get-app.uvue @@ -1,33 +1,99 @@ + + +