style: add eslint and prettier, fix style errors

This commit is contained in:
2026-02-13 09:59:19 +05:00
parent 5d6159fe29
commit 387c1751c6
101 changed files with 14596 additions and 12946 deletions
+13 -13
View File
@@ -1,13 +1,13 @@
import TextConfig from "$components/text/TextConfig.svelte";
import { cleanup, render } from "@testing-library/svelte";
import { afterEach, describe, it } from "vitest";
afterEach(() => {
cleanup();
});
describe("TextConfig.svelte", () => {
it("should render without crashing", () => {
render(TextConfig);
});
});
import TextConfig from "$components/text/TextConfig.svelte";
import { cleanup, render } from "@testing-library/svelte";
import { afterEach, describe, it } from "vitest";
afterEach(() => {
cleanup();
});
describe("TextConfig.svelte", () => {
it("should render without crashing", () => {
render(TextConfig);
});
});
@@ -1,36 +1,36 @@
import TextInlineEdit from "$components/text/TextInlineEdit.svelte";
import { cleanup, render, screen } from "@testing-library/svelte";
import { afterEach, describe, expect, it } from "vitest";
afterEach(() => {
cleanup();
});
describe("TextInlineEdit.svelte", () => {
it("should render with initial text", () => {
render(TextInlineEdit, {
props: {
id: 1,
text: "Test text",
ondelete: () => {},
},
});
const input = screen.getByRole("textbox");
expect(input).toBeInTheDocument();
expect(input).toHaveValue("Test text");
});
it("should render with empty text", () => {
render(TextInlineEdit, {
props: {
id: 1,
text: "",
ondelete: () => {},
},
});
const input = screen.getByRole("textbox");
expect(input).toHaveValue("");
});
});
import TextInlineEdit from "$components/text/TextInlineEdit.svelte";
import { cleanup, render, screen } from "@testing-library/svelte";
import { afterEach, describe, expect, it } from "vitest";
afterEach(() => {
cleanup();
});
describe("TextInlineEdit.svelte", () => {
it("should render with initial text", () => {
render(TextInlineEdit, {
props: {
id: 1,
text: "Test text",
ondelete: () => {},
},
});
const input = screen.getByRole("textbox");
expect(input).toBeInTheDocument();
expect(input).toHaveValue("Test text");
});
it("should render with empty text", () => {
render(TextInlineEdit, {
props: {
id: 1,
text: "",
ondelete: () => {},
},
});
const input = screen.getByRole("textbox");
expect(input).toHaveValue("");
});
});
+61 -61
View File
@@ -1,61 +1,61 @@
import TextInput from "$components/text/TextInput.svelte";
import { render, screen } from "@testing-library/svelte";
import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
describe("TextInput.svelte", () => {
it("should render with initial value", () => {
render(TextInput, {
props: {
text: "Test text",
onenter: vi.fn(),
ariaLabel: "Test input",
},
});
const input = screen.getByRole("textbox", { name: /test input/i });
expect(input).toBeInTheDocument();
expect(input).toHaveValue("Test text");
});
it("should update value on input", async () => {
const user = userEvent.setup();
render(TextInput, {
props: {
text: "Initial",
onenter: vi.fn(),
ariaLabel: "Test input",
},
});
const input = screen.getByRole("textbox", { name: /test input/i });
await user.clear(input);
await user.type(input, "Updated text");
expect(input).toHaveValue("Updated text");
});
it("should call onenter only on Enter key and not on others", async () => {
const user = userEvent.setup();
const onenterSpy = vi.fn();
render(TextInput, {
props: {
text: "test",
onenter: onenterSpy,
ariaLabel: "Test input",
},
});
const input = screen.getByRole("textbox", { name: /test input/i });
await user.type(input, "abc");
expect(onenterSpy).not.toHaveBeenCalled();
await user.keyboard("{Escape}");
expect(onenterSpy).not.toHaveBeenCalled();
await user.type(input, "{Enter}");
expect(onenterSpy).toHaveBeenCalledTimes(1);
});
});
import TextInput from "$components/text/TextInput.svelte";
import { render, screen } from "@testing-library/svelte";
import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
describe("TextInput.svelte", () => {
it("should render with initial value", () => {
render(TextInput, {
props: {
text: "Test text",
onenter: vi.fn(),
ariaLabel: "Test input",
},
});
const input = screen.getByRole("textbox", { name: /test input/i });
expect(input).toBeInTheDocument();
expect(input).toHaveValue("Test text");
});
it("should update value on input", async () => {
const user = userEvent.setup();
render(TextInput, {
props: {
text: "Initial",
onenter: vi.fn(),
ariaLabel: "Test input",
},
});
const input = screen.getByRole("textbox", { name: /test input/i });
await user.clear(input);
await user.type(input, "Updated text");
expect(input).toHaveValue("Updated text");
});
it("should call onenter only on Enter key and not on others", async () => {
const user = userEvent.setup();
const onenterSpy = vi.fn();
render(TextInput, {
props: {
text: "test",
onenter: onenterSpy,
ariaLabel: "Test input",
},
});
const input = screen.getByRole("textbox", { name: /test input/i });
await user.type(input, "abc");
expect(onenterSpy).not.toHaveBeenCalled();
await user.keyboard("{Escape}");
expect(onenterSpy).not.toHaveBeenCalled();
await user.type(input, "{Enter}");
expect(onenterSpy).toHaveBeenCalledTimes(1);
});
});
+60 -60
View File
@@ -1,60 +1,60 @@
import TextManager from "$components/text/TextManager.svelte";
import { textsState } from "$states/texts.svelte";
import { render, screen } from "@testing-library/svelte";
import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it } from "vitest";
describe("TextManager", () => {
beforeEach(() => {
textsState.clear();
});
it("should add text to state and clear input on button click", async () => {
const user = userEvent.setup();
render(TextManager);
const input = screen.getByRole("textbox", { name: /input new text/i });
const addButton = screen.getByRole("button", { name: /add text/i });
await user.type(input, "New Note");
await user.click(addButton);
expect(textsState.texts).toHaveLength(1);
expect(textsState.texts[0].text).toBe("New Note");
expect(input).toHaveValue("");
});
it("should add text on enter key", async () => {
const user = userEvent.setup();
render(TextManager);
const input = screen.getByRole("textbox", { name: /input new text/i });
await user.type(input, "Enter Note{Enter}");
expect(textsState.texts).toHaveLength(1);
expect(textsState.texts[0].text).toBe("Enter Note");
});
it("should display all items from state", async () => {
textsState.addText("First");
textsState.addText("Second");
render(TextManager);
const items = screen.getAllByRole("listitem");
expect(items).toHaveLength(2);
});
it("should remove text from state when delete button is clicked", async () => {
const user = userEvent.setup();
textsState.addText("To be deleted");
render(TextManager);
const deleteBtn = screen.getByRole("button", { name: /delete/i });
await user.click(deleteBtn);
expect(textsState.texts).toHaveLength(0);
});
});
import TextManager from "$components/text/TextManager.svelte";
import { textsState } from "$states/texts.svelte";
import { render, screen } from "@testing-library/svelte";
import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it } from "vitest";
describe("TextManager", () => {
beforeEach(() => {
textsState.clear();
});
it("should add text to state and clear input on button click", async () => {
const user = userEvent.setup();
render(TextManager);
const input = screen.getByRole("textbox", { name: /input new text/i });
const addButton = screen.getByRole("button", { name: /add text/i });
await user.type(input, "New Note");
await user.click(addButton);
expect(textsState.texts).toHaveLength(1);
expect(textsState.texts[0].text).toBe("New Note");
expect(input).toHaveValue("");
});
it("should add text on enter key", async () => {
const user = userEvent.setup();
render(TextManager);
const input = screen.getByRole("textbox", { name: /input new text/i });
await user.type(input, "Enter Note{Enter}");
expect(textsState.texts).toHaveLength(1);
expect(textsState.texts[0].text).toBe("Enter Note");
});
it("should display all items from state", async () => {
textsState.addText("First");
textsState.addText("Second");
render(TextManager);
const items = screen.getAllByRole("listitem");
expect(items).toHaveLength(2);
});
it("should remove text from state when delete button is clicked", async () => {
const user = userEvent.setup();
textsState.addText("To be deleted");
render(TextManager);
const deleteBtn = screen.getByRole("button", { name: /delete/i });
await user.click(deleteBtn);
expect(textsState.texts).toHaveLength(0);
});
});