Files
Shudhanshu Singhandsilverwind 496b2d6748 fix: handle task list items checked with uppercase X (#40334)
Markdown renders `[X]` as a checked task like `[x]`, but parts of the
frontend only recognize lowercase `x`.

- Clicking a `[X]` checkbox now unchecks it instead of failing.
- Pressing Enter on a `- [X]` line in the editor continues the list with
`- [ ] ` instead of dropping the checkbox.

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-12 10:10:02 +00:00

11 lines
563 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('- [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');
});