24 lines
1.5 KiB
TypeScript
24 lines
1.5 KiB
TypeScript
/**
|
|
* 46-github: GitHub Desktop Vue 组件化测试
|
|
* 覆盖: 仓库名/徽章(★1024,⑂128)、README 内容、代码块、卸载
|
|
*/
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
import { h, render } from 'vue'
|
|
import GitHubComponent from '../../src/apps/github/GitHub.vue'
|
|
import { setupDOM } from '../helpers'
|
|
|
|
describe('46-github', () => {
|
|
let body: HTMLElement
|
|
beforeEach(() => { setupDOM(); const el = document.createElement('div'); el.className = 'window'; document.body.appendChild(el); body = document.createElement('div'); body.className = 'win-body'; el.appendChild(body); (window as any).WM = { setTitle() {} } })
|
|
afterEach(() => { render(null, body); (body.parentElement as HTMLElement)?.remove() })
|
|
function m() { render(h(GitHubComponent, {}), body) }
|
|
|
|
it('仓库名显示', () => { m(); expect(body.querySelector('.gh-repo')?.textContent).toContain('macos-web') })
|
|
it('Star 徽章 1024', () => { m(); expect(body.querySelector('.gh-badge')?.textContent).toContain('1024') })
|
|
it('Fork 徽章 128', () => { m(); const badges = body.querySelectorAll('.gh-badge'); expect(badges[1]?.textContent).toContain('128') })
|
|
it('README 标题', () => { m(); expect(body.querySelector('.gh-readme h2')?.textContent).toBe('macos-web') })
|
|
it('代码块存在', () => { m(); expect(body.querySelector('.sf-code')).toBeTruthy() })
|
|
it('特性列表', () => { m(); expect(body.querySelector('.gh-readme')?.textContent).toContain('窗口管理器') })
|
|
it('卸载', () => { m(); render(null, body); expect(body.children.length).toBe(0) })
|
|
})
|