34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { CHANGE_STYLES, changeOf, reviewBaseFile } from './changedFiles'
|
|
|
|
describe('改动状态', () => {
|
|
it('新增 A、删除 D,别的(改名、复制、改了、没改)都算修改 M', () => {
|
|
expect(changeOf('added')).toBe('A')
|
|
expect(changeOf('deleted')).toBe('D')
|
|
for (const status of ['changed', 'modified', 'renamed', 'copied', 'unchanged', ''])
|
|
expect(changeOf(status)).toBe('M')
|
|
})
|
|
|
|
it('颜色照 VS Code 源代码管理的 git 装饰色,删掉的提示「PR 里删掉了」', () => {
|
|
expect(CHANGE_STYLES.M.color).toBe('gitDecoration.modifiedResourceForeground')
|
|
expect(CHANGE_STYLES.A.color).toBe('gitDecoration.addedResourceForeground')
|
|
expect(CHANGE_STYLES.D.color).toBe('gitDecoration.deletedResourceForeground')
|
|
expect(CHANGE_STYLES.D.tooltip).toBe('PR 里删掉了')
|
|
})
|
|
})
|
|
|
|
describe('审查时在 PR 目标分支上取哪个文件', () => {
|
|
const files = [
|
|
{ path: 'src/new.ts', status: 'added' },
|
|
{ path: 'src/moved.ts', status: 'renamed', previousFilename: 'src/old.ts' },
|
|
{ path: 'src/changed.ts', status: 'changed' },
|
|
]
|
|
|
|
it('新加的目标分支上没有,改名的取改名前的路径,别的照原路径', () => {
|
|
expect(reviewBaseFile(files, 'src/new.ts')).toEqual({ path: 'src/new.ts', added: true })
|
|
expect(reviewBaseFile(files, 'src/moved.ts')).toEqual({ path: 'src/old.ts', added: false })
|
|
expect(reviewBaseFile(files, 'src/changed.ts')).toEqual({ path: 'src/changed.ts', added: false })
|
|
expect(reviewBaseFile(files, 'src/untouched.ts')).toEqual({ path: 'src/untouched.ts', added: false })
|
|
})
|
|
})
|