Co-authored-by: Steve Dudenhoeffer <[email protected]>
This commit was merged in pull request #71.
This commit is contained in:
@@ -113,3 +113,29 @@ describe('totalChanges', () => {
|
||||
).toBe(13)
|
||||
})
|
||||
})
|
||||
|
||||
describe('describeUndo with an unknown total', () => {
|
||||
// The chat panel offers Undo on a turn knowing only its change set id — the
|
||||
// agent's reply carries the id, not the tally. Inventing a denominator to
|
||||
// fill the sentence would be worse than not having one.
|
||||
it("doesn't invent a denominator it was never given", () => {
|
||||
const out = describeUndo(
|
||||
{ id: 5 },
|
||||
{
|
||||
changeSet: changeSet({ id: 6, counts: [{ entityType: 'planting', op: 'delete', n: 2 }] }),
|
||||
conflicts: [{ entityType: 'object', entityId: 7, reason: 'changed', name: 'North Bed' }],
|
||||
},
|
||||
)
|
||||
expect(out.tone).toBe('partial')
|
||||
expect(out.message).toBe('Partly undone — “North Bed” was edited since, so it was left alone.')
|
||||
expect(out.message).not.toMatch(/\d+ of \d+/)
|
||||
})
|
||||
|
||||
it('still reports a clean undo the same way', () => {
|
||||
const out = describeUndo(
|
||||
{ id: 5 },
|
||||
{ changeSet: changeSet({ id: 6, counts: [{ entityType: 'object', op: 'update', n: 1 }] }), conflicts: [] },
|
||||
)
|
||||
expect(out).toEqual({ tone: 'ok', message: 'Undone.' })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user