刘光辉
8 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { describe, expect, it } from 'vitest';
 
import { reconcileDocumentValue } from '../../src/domain/conflict';
 
describe('reconcileDocumentValue', () => {
  it('adopts document edits when the sidebar draft still equals its baseline', () => {
    expect(reconcileDocumentValue('原值', '原值', '文档新值')).toEqual({
      documentValue: '文档新值',
      draftValue: '文档新值',
    });
  });
 
  it('acknowledges the document when it already equals the sidebar draft', () => {
    expect(reconcileDocumentValue('原值', '草稿', '草稿')).toEqual({
      documentValue: '草稿',
      draftValue: '草稿',
    });
  });
 
  it('keeps a sidebar draft when the document has not moved from its baseline', () => {
    expect(reconcileDocumentValue('原值', '草稿', '原值')).toEqual({
      documentValue: '原值',
      draftValue: '草稿',
    });
  });
 
  it('reports a conflict only when the document and draft diverge from the same baseline', () => {
    expect(reconcileDocumentValue('原值', '侧栏值', '文档值')).toEqual({
      conflict: { baseValue: '原值', documentValue: '文档值', draftValue: '侧栏值' },
      documentValue: '文档值',
      draftValue: '侧栏值',
    });
  });
});