Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
wtto00 committed Dec 3, 2024
1 parent e6fb4aa commit 9eddeda
Showing 1 changed file with 2 additions and 49 deletions.
51 changes: 2 additions & 49 deletions tests/android.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import assert from 'node:assert'
import { rm, writeFileSync } from 'node:fs'
import { rm } from 'node:fs'
import { after, before, describe, it } from 'node:test'
import { execaSync } from 'execa'
import { readJsonFile } from '../src/utils/file.js'
import Log from '../src/utils/log.js'
import { AndroidAbiFilters, type ManifestConfig } from '../src/utils/manifest.config.js'
import { execaUniapp, execaUniappSync } from './helper.js'

describe('android', () => {
Expand Down Expand Up @@ -34,52 +32,7 @@ describe('android', () => {

it('add', { timeout: 60000 }, async () => {
const { stdout } = await execaUniapp('platform add android')

assert.equal(stdout, Log.errorColor('平台 android 添加失败: 请在文件manifest.json中配置应用名称: name'))
const manifest = readJsonFile<ManifestConfig>('src/manifest.json', true)

manifest.name = 'Test Project Platform'
writeFileSync('src/manifest.json', JSON.stringify(manifest, null, 2), 'utf8')
const { stdout: stdout1 } = await execaUniapp('platform add android')
assert.equal(stdout1, Log.errorColor('平台 android 添加失败: 请在文件manifest.json中配置应用appid: appid'))

manifest.appid = '__UNI__1FC8DF9'
writeFileSync('src/manifest.json', JSON.stringify(manifest, null, 2), 'utf8')
const { stdout: stdout2 } = await execaUniapp('platform add android')
assert.equal(
stdout2,
Log.errorColor(
'平台 android 添加失败: 请在文件manifest.json中配置应用Appkey: app-plus.distribute.android.dcloud_appkey',
),
)

if (manifest['app-plus']?.distribute?.android)
manifest['app-plus'].distribute.android.dcloud_appkey = 'c1b4ac7b9a38a1036528ac460ac70f18'
writeFileSync('src/manifest.json', JSON.stringify(manifest, null, 2), 'utf8')
const { stdout: stdout3 } = await execaUniapp('platform add android')
assert.equal(
stdout3,
Log.errorColor(
'平台 android 添加失败: 请在文件manifest.json中配置应用包名: app-plus.distribute.android.packagename',
),
)

if (manifest['app-plus']?.distribute?.android)
manifest['app-plus'].distribute.android.packagename = 'com.example.uniapp'
writeFileSync('src/manifest.json', JSON.stringify(manifest, null, 2), 'utf8')
const { stdout: stdout4 } = await execaUniapp('platform add android')
assert.equal(
stdout4,
Log.errorColor(
'平台 android 添加失败: 请在文件manifest.json中配置应用所支持的CPU类型: app-plus.distribute.android.abiFilters',
),
)

if (manifest['app-plus']?.distribute?.android)
manifest['app-plus'].distribute.android.abiFilters = [AndroidAbiFilters.x64, AndroidAbiFilters.ARM64]
writeFileSync('src/manifest.json', JSON.stringify(manifest, null, 2), 'utf8')
const { stdout: stdout5 } = await execaUniapp('platform add android')
assert.equal(stdout5, Log.successColor('平台 android 已成功添加'))
assert.equal(stdout, Log.successMessage('平台 android 已成功添加'))
})

it('remove', { timeout: 60000, todo: true })
Expand Down

0 comments on commit 9eddeda

Please sign in to comment.