test(workbench): lock cross-domain edit history
This commit is contained in:
1 parent
bb6c51c489
commit
2fb9db65e5
3 files changed
+78
-24
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { clearEditHistory, recordEdit, takeRedoDomain, takeUndoDomain, type EditHistory } from './edit-history';
|
||||
|
||||
const history = (): EditHistory => ({ undo: [], redo: [] });
|
||||
|
||||
describe('edit history domains', () => {
|
||||
it('undoes the most recent domain across session and signal stacks', () => {
|
||||
const value = history();
|
||||
recordEdit(value, 'session');
|
||||
recordEdit(value, 'signal');
|
||||
expect(takeUndoDomain(value)).toBe('signal');
|
||||
expect(takeUndoDomain(value)).toBe('session');
|
||||
});
|
||||
|
||||
it('redo preserves the same cross-domain order', () => {
|
||||
const value = history();
|
||||
recordEdit(value, 'session');
|
||||
recordEdit(value, 'signal');
|
||||
takeUndoDomain(value);
|
||||
expect(takeRedoDomain(value)).toBe('signal');
|
||||
expect(value.undo).toEqual(['session', 'signal']);
|
||||
});
|
||||
|
||||
it('clears redo after a new edit', () => {
|
||||
const value = history();
|
||||
recordEdit(value, 'session');
|
||||
takeUndoDomain(value);
|
||||
recordEdit(value, 'signal');
|
||||
expect(value.redo).toEqual([]);
|
||||
});
|
||||
|
||||
it('clears both stacks', () => {
|
||||
const value = history();
|
||||
recordEdit(value, 'session');
|
||||
takeUndoDomain(value);
|
||||
clearEditHistory(value);
|
||||
expect(value).toEqual({ undo: [], redo: [] });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user