package com.cottondb.notes import org.junit.Assert.assertEquals import org.junit.Test /** An open note another writer changed is drawn again with the person's cursor on the words they were at (STALE, 21 Nov 2026). */ class NoteReloadCursorTest { private val before = "Weekend in Hampi\n\n- [x] Book the bus\n- [ ] Guesthouse" private val after = "Weekend in Hampi\n\nLeave Friday after work.\n\n- [x] Book the bus\n- [ ] Guesthouse\n- [ ] Sunrise" @Test fun a_cursor_above_what_changed_stays() { assertEquals(5, movedCursor(before, after, 5)) } @Test fun a_cursor_below_lines_added_above_moves_with_its_words() { val at = before.indexOf("Guesthouse") assertEquals(after.indexOf("Guesthouse"), movedCursor(before, after, at)) } @Test fun a_cursor_at_the_end_stays_on_its_words_and_never_past_the_text() { assertEquals("- [ ] Sunrise".length, movedCursor("x\n- [ ] Sunrise", "y\nz\n- [ ] Sunrise", "x\n- [ ] Sunrise".length) - "y\nz\n".length) assertEquals(0, movedCursor("abc", "", 2)) } }