✨ feat(vscode): 注释里的仓库图片按比例显示
This commit is contained in:
1 parent
57b2f2a115
commit
9faf9cde9e
13 files changed
+312
-8
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import type { WebviewToExtension } from './types'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { repoImageInner, RepoImages } from './repoImage'
|
||||
|
||||
describe('repoImages', () => {
|
||||
function setup(): { images: RepoImages, sent: WebviewToExtension[] } {
|
||||
const sent: WebviewToExtension[] = []
|
||||
return { images: new RepoImages(msg => sent.push(msg)), sent }
|
||||
}
|
||||
|
||||
it('路径变了才问哪些在,还没回是路径,不在是找不到图片,迟到的回答丢掉', () => {
|
||||
const { images, sent } = setup()
|
||||
const path = 'frontend/src/components/overview/screenshots/OverviewSection.png'
|
||||
images.scan([path])
|
||||
images.scan([path])
|
||||
expect(sent).toEqual([{ type: 'checkRepoImages', id: 1, paths: [path] }])
|
||||
expect(images.state(path)).toBe('pending')
|
||||
expect(repoImageInner(path, '概览卡片', images.state(path))).toBe(path)
|
||||
|
||||
expect(images.checked(0, [{ path }])).toBe(false)
|
||||
expect(images.state(path)).toBe('pending')
|
||||
expect(images.checked(1, [{ path }])).toBe(true)
|
||||
expect(images.state(path)).toBe('missing')
|
||||
expect(repoImageInner(path, '概览卡片', 'missing')).toBe(`找不到图片 ${path}`)
|
||||
expect(repoImageInner(path, '概览卡片', 'missing')).not.toContain('<img')
|
||||
|
||||
const src = 'https://file+.vscode-resource.vscode-cdn.net/OverviewSection.png'
|
||||
expect(images.checked(1, [{ path, src }])).toBe(true)
|
||||
expect(repoImageInner(path, '概览卡片', images.state(path))).toContain('<img')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user