Files
gitea/web_src/js/markup/tasklist.test.ts
silverwind 50a1dc9486 Make task list checkboxes clickable in the preview tab (#37010)
When a checkbox is toggled in the markup preview tab, the change is now
synced back to the editor textarea. Extracted a `toggleTasklistCheckbox`
helper to deduplicate the byte-offset toggle logic.

---------

Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
2026-03-29 18:48:40 +00:00

10 lines
483 B
TypeScript

import {toggleTasklistCheckbox} from './tasklist.ts';
test('toggleTasklistCheckbox', () => {
expect(toggleTasklistCheckbox('- [ ] task', 3, true)).toEqual('- [x] task');
expect(toggleTasklistCheckbox('- [x] task', 3, false)).toEqual('- [ ] task');
expect(toggleTasklistCheckbox('- [ ] task', 0, true)).toBeNull();
expect(toggleTasklistCheckbox('- [ ] task', 99, true)).toBeNull();
expect(toggleTasklistCheckbox('😀 - [ ] task', 8, true)).toEqual('😀 - [x] task');
});