73 lines
3.4 KiB
JavaScript
73 lines
3.4 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
describe('home page compatibility', () => {
|
|
test('avoids fragile WXSS layout features for the native miniprogram renderer', () => {
|
|
const wxss = fs.readFileSync(path.join(process.cwd(), 'pages/home/index.wxss'), 'utf8')
|
|
|
|
expect(wxss).not.toContain('display: grid')
|
|
expect(wxss).not.toContain('width: fit-content')
|
|
expect(wxss).not.toContain('gap:')
|
|
})
|
|
|
|
test('renders existing sections and the new wellness/classics blocks with compatible layouts', () => {
|
|
const wxml = fs.readFileSync(path.join(process.cwd(), 'pages/home/index.wxml'), 'utf8')
|
|
const wxss = fs.readFileSync(path.join(process.cwd(), 'pages/home/index.wxss'), 'utf8')
|
|
|
|
expect(wxml).not.toContain('quick-links')
|
|
expect(wxml).not.toContain('floating-actions')
|
|
expect(wxml).not.toContain('home-page__corner')
|
|
expect(wxml).not.toContain('home-page__header')
|
|
expect(wxml).toContain('{{wellnessTitle}}')
|
|
expect(wxml).toContain('{{classicsTitle}}')
|
|
expect(wxml).toContain('{{classicsActionText}}')
|
|
expect(wxml).toContain('bindtap="handleSearchTap"')
|
|
expect(wxml).toContain('bindtap="handleEncyclopediaTap"')
|
|
expect(wxml).toContain('bindtap="handleToolTap"')
|
|
expect(wxml).toContain('bindtap="handleWellnessTap"')
|
|
expect(wxml).toContain('bindtap="handleClassicActionTap"')
|
|
expect(wxml).toContain('bindtap="handleClassicTap"')
|
|
expect(wxml).toContain('feature-grid feature-grid--three')
|
|
expect(wxml.match(/feature-grid feature-grid--four/g)).toHaveLength(3)
|
|
expect(wxml.match(/feature-grid feature-grid--three/g)).toHaveLength(1)
|
|
expect(wxml).toContain('section-card__header')
|
|
expect(wxml).toContain('feature-card__book')
|
|
|
|
expect(wxss).toContain('.feature-grid--four .feature-card')
|
|
expect(wxss).toContain('.feature-grid--three .feature-grid__item')
|
|
expect(wxss).toContain('.section-card__header')
|
|
expect(wxss).toContain('.section-card__action')
|
|
expect(wxss).toContain('.feature-card__book')
|
|
expect(wxss).not.toContain('.home-page__corner')
|
|
expect(wxss).not.toContain('.home-page__header')
|
|
expect(wxss).toContain('padding: 12rpx 18rpx 36rpx;')
|
|
expect(wxss).toContain('padding: 24rpx 18rpx 16rpx;')
|
|
expect(wxss).toContain('font-size: 60rpx;')
|
|
expect(wxss).toContain('font-size: 42rpx;')
|
|
expect(wxss).toContain('min-height: 152rpx;')
|
|
})
|
|
|
|
test('renders the portal section without forbidden grid or gap styles', () => {
|
|
const wxml = fs.readFileSync(path.join(process.cwd(), 'pages/home/index.wxml'), 'utf8')
|
|
const wxss = fs.readFileSync(path.join(process.cwd(), 'pages/home/index.wxss'), 'utf8')
|
|
|
|
expect(wxml).toContain('{{portalTitle}}')
|
|
expect(wxml).toContain('portal-grid')
|
|
expect(wxml).toContain('bindtap="handlePortalTap"')
|
|
expect(wxss).toContain('.portal-grid')
|
|
expect(wxss).toContain('.portal-card')
|
|
expect(wxss).not.toContain('display: grid')
|
|
expect(wxss).not.toContain('gap:')
|
|
})
|
|
|
|
test('renders encyclopedia section before the learning portal section', () => {
|
|
const wxml = fs.readFileSync(path.join(process.cwd(), 'pages/home/index.wxml'), 'utf8')
|
|
const encyclopediaIndex = wxml.indexOf('{{encyclopediaTitle}}')
|
|
const portalIndex = wxml.indexOf('{{portalTitle}}')
|
|
|
|
expect(encyclopediaIndex).toBeGreaterThan(-1)
|
|
expect(portalIndex).toBeGreaterThan(-1)
|
|
expect(encyclopediaIndex).toBeLessThan(portalIndex)
|
|
})
|
|
})
|