新增分类页面及图标资源,完善底部导航分类 tab,新增 navbar 度量工具适配不同设备,优化请求参数处理,修复通知相关显示问题,统一顶部导航栏样式以适配系统状态栏与胶囊避让。
45 行
1.4 KiB
JavaScript
45 行
1.4 KiB
JavaScript
/**
|
|
* 顶部导航栏与胶囊避让度量工具单测
|
|
*/
|
|
import { describe, it, expect } from './harness.mjs'
|
|
import { getNavMetrics } from '../common/utils/navbar.js'
|
|
|
|
describe('顶部导航栏 · 规范度量与胶囊避让', () => {
|
|
it('无 uni 环境或默认兜底时返回安全度量', () => {
|
|
const m = getNavMetrics()
|
|
expect(typeof m.statusBarHeight).toBe('number')
|
|
expect(typeof m.navBarHeight).toBe('number')
|
|
expect(typeof m.capsulePadding).toBe('number')
|
|
expect(typeof m.totalHeight).toBe('number')
|
|
expect(m.statusBarHeight >= 0).toBe(true)
|
|
expect(m.navBarHeight >= 38).toBe(true)
|
|
expect(m.totalHeight).toBe(m.statusBarHeight + m.navBarHeight)
|
|
})
|
|
|
|
it('模拟微信小程序环境精确计算胶囊避让与导航栏高度', () => {
|
|
const originalUni = globalThis.uni
|
|
try {
|
|
globalThis.uni = {
|
|
getSystemInfoSync: () => ({ statusBarHeight: 44, windowWidth: 390 }),
|
|
getMenuButtonBoundingClientRect: () => ({
|
|
left: 280,
|
|
right: 380,
|
|
top: 48,
|
|
bottom: 80,
|
|
width: 100,
|
|
height: 32,
|
|
}),
|
|
}
|
|
const m = getNavMetrics()
|
|
expect(m.statusBarHeight).toBe(44)
|
|
// capsulePadding = (390 - 280) + 8 = 118
|
|
expect(m.capsulePadding).toBe(118)
|
|
// navBarHeight = (48 - 44) * 2 + 32 = 40
|
|
expect(m.navBarHeight).toBe(40)
|
|
expect(m.totalHeight).toBe(84)
|
|
} finally {
|
|
globalThis.uni = originalUni
|
|
}
|
|
})
|
|
})
|