返回 oh-my-ppt
app-structure.test.ts
根目录 / tests / unit / app / app-structure.test.ts
1 import fs from 'fs'
2 import { describe, expect, it } from 'vitest'
3
4 describe('main app structure', () => {
5 it('keeps window, menu, tray, and lifecycle implementation outside the bootstrap entry', () => {
6 for (const filePath of [
7 'src/main/app/window.ts',
8 'src/main/app/menu.ts',
9 'src/main/app/tray.ts',
10 'src/main/app/lifecycle.ts',
11 'src/main/app/renderer-recovery.ts',
12 'src/main/app/application.ts'
13 ]) {
14 expect(fs.existsSync(filePath), filePath).toBe(true)
15 }
16
17 expect(fs.existsSync('src/main/tray.ts')).toBe(false)
18 expect(fs.existsSync('src/main/renderer-recovery.ts')).toBe(false)
19 })
20
21 it('leaves the bootstrap responsible for composition rather than window implementation', () => {
22 const bootstrap = fs.readFileSync('src/main/index.ts', 'utf8')
23
24 expect(bootstrap).toContain("from './app/application'")
25 expect(bootstrap).not.toContain("from './app/window'")
26 expect(bootstrap).not.toContain("from './app/lifecycle'")
27 expect(bootstrap).not.toContain("from './app/tray'")
28 expect(bootstrap).not.toContain('function resolveWindowBounds')
29 expect(bootstrap).not.toContain('function configureLogging')
30 expect(bootstrap).not.toContain('function scheduleUpdateNotification')
31 })
32
33 it('resolves packaged assets from the bundled main-process output directory', () => {
34 const windowModule = fs.readFileSync('src/main/app/window.ts', 'utf8')
35 const trayModule = fs.readFileSync('src/main/app/tray.ts', 'utf8')
36
37 expect(windowModule).toContain('const mainOutputDir = __dirname')
38 expect(windowModule).toContain("join(mainOutputDir, '../preload/index.mjs')")
39 expect(windowModule).toContain("join(mainOutputDir, '../renderer/index.html')")
40 expect(trayModule).toContain('const mainOutputDir = __dirname')
41 expect(trayModule).toContain("join(mainOutputDir, '../../build/icons')")
42 })
43 })
44
44 lines TYPESCRIPT