💄 style(vscode): 代码阅读的「按注释规范写注释」按钮统一排在卡片右上角那排最前面,不再画在「注释」一行上
This commit is contained in:
1 parent
c398a538d9
commit
ebea984852
7 files changed
+52
-68
No files matched your search
@@ -111,29 +111,31 @@ describe('挂在卡片子行上的子块', () => {
|
||||
describe('「注释」一行和「重写注释」按钮', () => {
|
||||
const comment = { label: '注释', value: { markdown: '按名字找' } }
|
||||
const html = (block: BlockView): string => renderToStaticMarkup(<BlockLevel blocks={[block]} tree={state(new Set())} />)
|
||||
/** 「注释」那一行(cr-prop-row)里的 HTML */
|
||||
const commentRowHtml = (markup: string): string => markup.split('cr-prop-row').find(part => part.includes('按名字找')) ?? ''
|
||||
/** 按钮只有一个,排在右上角那排按钮(块操作)的最前面 */
|
||||
const inToolbar = (markup: string, label: string): void => {
|
||||
expect(markup.match(new RegExp(`aria-label="${label}"`, 'g'))).toHaveLength(1)
|
||||
expect(markup).toMatch(new RegExp(`role="group" aria-label="块操作"><button[^>]*aria-label="${label}"`))
|
||||
}
|
||||
|
||||
it('属性表卡片:「注释」一行照属性表画,按钮画在这一行上,右上角那排不再有', () => {
|
||||
it('属性表卡片:「注释」一行照属性表画,按钮在右上角那排,不在这一行上', () => {
|
||||
const card = view('1', 'function', '', {
|
||||
properties: [{ label: '名称', value: [{ text: 'find', role: 'function' }] }, comment, { label: '异步', value: [{ text: '否', role: 'storage' }] }],
|
||||
commentRow: 1,
|
||||
commentTarget: { kind: 'replace', startLine: 0, endLine: 0 },
|
||||
})
|
||||
const markup = html(card)
|
||||
expect(commentRowHtml(markup)).toContain('aria-label="按注释规范重写"')
|
||||
expect(markup.match(/aria-label="按注释规范重写"/g)).toHaveLength(1)
|
||||
inToolbar(markup, '按注释规范重写')
|
||||
expect(markup.indexOf('按名字找')).toBeLessThan(markup.indexOf('异步'))
|
||||
})
|
||||
|
||||
it('一行译文的卡片:「注释」一行排在译文下面,按钮同样在这一行上', () => {
|
||||
it('一行译文的卡片:「注释」一行排在译文下面,按钮同样在右上角那排', () => {
|
||||
const markup = html(view('2', 'statement', 'save()', { rows: [comment], commentRow: 0, commentTarget: { kind: 'replace', startLine: 0, endLine: 0 } }))
|
||||
expect(markup.indexOf('save()')).toBeLessThan(markup.indexOf('按名字找'))
|
||||
expect(commentRowHtml(markup)).toContain('aria-label="按注释规范重写"')
|
||||
inToolbar(markup, '按注释规范重写')
|
||||
})
|
||||
|
||||
it('还没有注释的块:按钮在右上角那排,叫「按注释规范写注释」;不能写注释的块没有按钮', () => {
|
||||
expect(html(view('3', 'statement', 'save()', { commentTarget: { kind: 'insert', line: 0 } }))).toMatch(/role="group" aria-label="块操作"><button[^>]*aria-label="按注释规范写注释"/)
|
||||
it('还没有注释的块:按钮同样在右上角那排,叫「按注释规范写注释」;不能写注释的块没有按钮', () => {
|
||||
inToolbar(html(view('3', 'statement', 'save()', { commentTarget: { kind: 'insert', line: 0 } })), '按注释规范写注释')
|
||||
expect(html(view('4', 'statement', 'save()'))).not.toContain('按注释规范')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user