« Modifier » turns the references dialog into a draft of adds and removes, saved as one update on the current citations. A new layer, citations, guards it between the finding and the reference dialogs: close, Back, POP refusal and the leave cascade ask it. « Modifier la référence » and « Nouvelle référence » stack the reference dialog over it; a creation it started joins its draft.
30 lines
986 B
TypeScript
30 lines
986 B
TypeScript
/** Rev 5 Task 12: the citations draft, held as additions and removals. */
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
addId,
|
|
applyEdits,
|
|
NO_EDITS,
|
|
removeId,
|
|
} from '@/editor/references/citationEdits'
|
|
|
|
describe('citation edits', () => {
|
|
it('applies removals and additions to the current list, each id once', () => {
|
|
const edits = addId(removeId(NO_EDITS, 'a'), 'b')
|
|
expect(applyEdits(['a', 'c'], edits)).toEqual(['c', 'b'])
|
|
expect(applyEdits(['a', 'b'], edits)).toEqual(['b'])
|
|
expect(applyEdits([], edits)).toEqual(['b'])
|
|
})
|
|
|
|
it('a removal then a citation of the same id is no change at all', () => {
|
|
expect(addId(removeId(NO_EDITS, 'a'), 'a')).toEqual(NO_EDITS)
|
|
expect(removeId(addId(NO_EDITS, 'n'), 'n')).toEqual(NO_EDITS)
|
|
})
|
|
|
|
it('a repeat is ignored', () => {
|
|
const once = addId(NO_EDITS, 'b')
|
|
expect(addId(once, 'b')).toBe(once)
|
|
const gone = removeId(NO_EDITS, 'a')
|
|
expect(removeId(gone, 'a')).toBe(gone)
|
|
})
|
|
})
|