83 lines
2.3 KiB
JavaScript
83 lines
2.3 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
function readJson(fileName) {
|
|
return JSON.parse(
|
|
fs.readFileSync(path.join(process.cwd(), fileName), {
|
|
encoding: 'utf8'
|
|
})
|
|
)
|
|
}
|
|
|
|
describe('project config', () => {
|
|
test('declares an explicit project name and base library version in root config', () => {
|
|
const projectConfig = readJson('project.config.json')
|
|
|
|
expect(projectConfig.projectname).toEqual(expect.any(String))
|
|
expect(projectConfig.projectname.trim()).not.toBe('')
|
|
expect(projectConfig.libVersion).toMatch(/^\d+\.\d+\.\d+$/)
|
|
})
|
|
|
|
test('registers native tab pages and matching tabBar items in app config', () => {
|
|
const appConfig = readJson('app.json')
|
|
const expectedTabPages = [
|
|
'pages/home/index',
|
|
'pages/library/index',
|
|
'pages/ai/index',
|
|
'pages/profile/index'
|
|
]
|
|
|
|
expect(appConfig.pages).toEqual(
|
|
expect.arrayContaining([...expectedTabPages, 'pages/login/index'])
|
|
)
|
|
expect(appConfig.tabBar).toEqual(
|
|
expect.objectContaining({
|
|
list: expect.arrayContaining(
|
|
expectedTabPages.map(pagePath =>
|
|
expect.objectContaining({
|
|
pagePath
|
|
})
|
|
)
|
|
)
|
|
})
|
|
)
|
|
expect(appConfig.tabBar.list).toHaveLength(4)
|
|
})
|
|
|
|
test('registers static migration subpackages in app config', () => {
|
|
const appConfig = readJson('app.json')
|
|
|
|
expect(appConfig.subPackages).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
root: 'packages/tcm',
|
|
pages: expect.arrayContaining([
|
|
'pages/ai-history/index',
|
|
'pages/assets/index',
|
|
'pages/bianzheng/index',
|
|
'pages/book-detail/index',
|
|
'pages/search-books/index',
|
|
'pages/section/index',
|
|
'pages/placeholder/index'
|
|
])
|
|
}),
|
|
expect.objectContaining({
|
|
root: 'packages/mingli',
|
|
pages: expect.arrayContaining([
|
|
'pages/hall/index',
|
|
'pages/bazi/index',
|
|
'pages/book-detail/index',
|
|
'pages/search-books/index',
|
|
'pages/section/index',
|
|
'pages/interpret/index'
|
|
])
|
|
}),
|
|
expect.objectContaining({
|
|
root: 'packages/learning',
|
|
pages: ['pages/center/index']
|
|
})
|
|
])
|
|
)
|
|
})
|
|
})
|