mirror of
https://github.com/mengxi-ream/read-frog.git
synced 2026-04-30 01:56:46 +00:00
test: cover split translator close toggle path
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
b4ce50ee1a
commit
e42ee07f4a
1 changed files with 14 additions and 3 deletions
|
|
@ -49,6 +49,19 @@ describe("splitTranslatorButton", () => {
|
|||
expect(toastInfoMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("is silent when the side panel is closed via toggle", async () => {
|
||||
sendMessageMock.mockResolvedValue({ ok: true, action: "closed" })
|
||||
|
||||
render(<SplitTranslatorButton />)
|
||||
fireEvent.click(screen.getByRole("button", { name: "popup.splitTranslator.open" }))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(sendMessageMock).toHaveBeenCalled()
|
||||
})
|
||||
expect(toastErrorMock).not.toHaveBeenCalled()
|
||||
expect(toastInfoMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("shows a Firefox sidebar hint when Firefox requires a browser user action", async () => {
|
||||
sendMessageMock.mockResolvedValue({ ok: false, reason: "requires-extension-user-action" })
|
||||
|
||||
|
|
@ -82,9 +95,7 @@ describe("splitTranslatorButton", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("uses localized labels and messages", async () => {
|
||||
sendMessageMock.mockResolvedValue({ ok: true, action: "opened" })
|
||||
|
||||
it("renders with a localized label", () => {
|
||||
render(<SplitTranslatorButton />)
|
||||
|
||||
expect(i18nTMock).toHaveBeenCalledWith("popup.splitTranslator.open")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue