mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-12 22:29:53 -06:00
Some checks failed
E2E Tests / e2e (push) Has been cancelled
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled
E2E Tests / publish-docs-screenshots (push) Has been cancelled
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import * as ConsoleCapture from "./ConsoleCapture";
|
|
|
|
describe("ConsoleCapture.formatConsoleArgs", () => {
|
|
test.each([
|
|
{ why: "plain strings", args: ["a", "b"], expected: "a b" },
|
|
{
|
|
why: "%s substitutions",
|
|
args: ["Warning: %s is %s", "key", "missing"],
|
|
expected: "Warning: key is missing",
|
|
},
|
|
{
|
|
why: "%c styles dropped",
|
|
args: ["%cstyled", "color: red"],
|
|
expected: "styled",
|
|
},
|
|
{ why: "escaped percent", args: ["100%%"], expected: "100%" },
|
|
{
|
|
why: "extra args appended",
|
|
args: ["%s!", "hi", { a: 1 }],
|
|
expected: 'hi! {"a":1}',
|
|
},
|
|
{ why: "non-string first arg", args: [1, true], expected: "1 true" },
|
|
])("$why", ({ args, expected }) => {
|
|
expect(ConsoleCapture.formatConsoleArgs(args)).toBe(expected);
|
|
});
|
|
});
|
|
|
|
describe("ConsoleCapture.isHydrationMessage", () => {
|
|
test.each([
|
|
["A tree hydrated but some attributes didn't match", true],
|
|
["Hydration failed because the server rendered HTML", true],
|
|
["Each child in a list should have a unique key", false],
|
|
])("%s", (message, expected) => {
|
|
expect(ConsoleCapture.isHydrationMessage(message)).toBe(expected);
|
|
});
|
|
});
|