diff --git a/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js b/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js index 46e34fcfe5e25eb8fe34bcc74085ca8e8e5311ab..61b247f1deea804846e9f6584db3b337a44a3155 100644 --- a/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js +++ b/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js @@ -1,25 +1,26 @@ -// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ -describe('API-saveImageToPhotosAlbum', () => { - if (process.env.uniTestPlatformInfo.startsWith('web') || process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { - it('pass', async () => { - expect(1).toBe(1); - }); - return; - } - - let page; - beforeAll(async () => { - page = await program.reLaunch('/pages/API/save-image-to-photos-album/save-image-to-photos-album'); - await page.waitFor(500); - }); - - it('test saveImageToPhotosAlbum', async () => { - if (process.env.uniTestPlatformInfo.startsWith('android')) { - await program.adbCommand( - 'pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE'); - await page.waitFor(500); - } - await page.callMethod('saveImage'); - expect(await page.data('success')).toBe(true); - }); +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isAndroid = platformInfo.startsWith('android') + + +describe('API-saveImageToPhotosAlbum', () => { + if (!isAndroid) { + it('pass', async () => { + expect(1).toBe(1); + }); + return; + } + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/API/save-image-to-photos-album/save-image-to-photos-album'); + await page.waitFor(500); + }); + + it('test saveImageToPhotosAlbum', async () => { + await program.adbCommand( + 'pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE'); + await page.waitFor(500); + await page.callMethod('saveImage'); + expect(await page.data('success')).toBe(true); + }); });