Cotton code
32 lines · 1.3 KB · KotlinRaw
package com.cottondb.daysimport com.cottondb.days.ui.NoteSentimport kotlinx.serialization.json.JsonNullimport kotlinx.serialization.json.JsonPrimitiveimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertNullimport org.junit.Test/** RULE (STALE, 21 Nov 2026): a note saved from the sheet carries the note the sheet opened with, so the core merges. */class DaysNoteSentTest {    @Test fun a_changed_note_goes_with_the_note_the_sheet_opened_with() {        val sent = NoteSent.change("- [ ] Pack the tent\n- [ ] Buy stove fuel", "- [x] Pack the tent\n- [ ] Buy stove fuel")!!        assertEquals(JsonPrimitive("- [x] Pack the tent\n- [ ] Buy stove fuel"), sent["note"])        assertEquals(JsonPrimitive("- [ ] Pack the tent\n- [ ] Buy stove fuel"), sent["note_base"])    }    @Test fun an_emptied_note_is_null_and_still_says_what_it_was() {        val sent = NoteSent.change("Call the plumber", "")!!        assertEquals(JsonNull, sent["note"])        assertEquals(JsonPrimitive("Call the plumber"), sent["note_base"])    }    @Test fun a_first_note_is_based_on_nothing() {        assertEquals(JsonPrimitive(""), NoteSent.change(null, "Bring the receipt")!!["note_base"])    }    @Test fun an_unchanged_note_sends_nothing() {        assertNull(NoteSent.change("Same words", "Same words"))        assertNull(NoteSent.change(null, ""))    }}