mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
Fix optimistic comment draft clearing
This commit is contained in:
parent
5e65bb2b92
commit
a7cfbc98f3
3 changed files with 48 additions and 3 deletions
31
ui/src/lib/comment-submit-draft.test.ts
Normal file
31
ui/src/lib/comment-submit-draft.test.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { restoreSubmittedCommentDraft } from "./comment-submit-draft";
|
||||
|
||||
describe("restoreSubmittedCommentDraft", () => {
|
||||
it("restores the submitted body when the editor is still empty after a failed request", () => {
|
||||
expect(
|
||||
restoreSubmittedCommentDraft({
|
||||
currentBody: "",
|
||||
submittedBody: "Retry me",
|
||||
}),
|
||||
).toBe("Retry me");
|
||||
});
|
||||
|
||||
it("treats whitespace-only input as empty when restoring a failed draft", () => {
|
||||
expect(
|
||||
restoreSubmittedCommentDraft({
|
||||
currentBody: " ",
|
||||
submittedBody: "Retry me",
|
||||
}),
|
||||
).toBe("Retry me");
|
||||
});
|
||||
|
||||
it("preserves newer input when the user has already typed again", () => {
|
||||
expect(
|
||||
restoreSubmittedCommentDraft({
|
||||
currentBody: "new draft",
|
||||
submittedBody: "Retry me",
|
||||
}),
|
||||
).toBe("new draft");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue