import {expect, test} from 'bun:test' import {continueList} from '@/lib/lists' const at = (s: string) => s.length test('a bullet goes on to the next line', () => { const s = 'issues:\n- one' expect(continueList(s, at(s))).toEqual({text: 'issues:\n- one\n- ', at: at('issues:\n- one\n- ')}) }) test('a number counts up, keeping its indent and its mark', () => { expect(continueList(' 3) three', 10)?.text).toBe(' 3) three\n 4) ') expect(continueList('1. one', 6)?.text).toBe('1. one\n2. ') }) test('Enter on an empty bullet ends the list', () => { const s = 'x\n- one\n- ' expect(continueList(s, at(s))).toEqual({text: 'x\n- one\n', at: at('x\n- one\n')}) }) test('a line that is no list item is left to the box', () => { expect(continueList('just words', 10)).toBeNull() expect(continueList('-not a bullet', 13)).toBeNull() }) test('in the middle of an item, the rest goes to the new item', () => { expect(continueList('- onetwo', 5)).toEqual({text: '- one\n- two', at: 8}) })