- Changed the default language in `index.html` from Russian to English, updating the title and button aria-labels for improved accessibility. - Refactored the `buildFetchOptions` function in `api.js` to include an optional external abort signal, enhancing request management. - Updated `fetchDuties` and `fetchCalendarEvents` to support request cancellation using the new abort signal, improving error handling. - Added unit tests for the API functions to ensure proper functionality, including handling of 403 errors and request cancellations. - Enhanced CSS styles for duty markers to improve visual consistency. - Removed unused code and improved the overall structure of the JavaScript files for better maintainability.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
/**
|
|
* Unit tests for escapeHtml edge cases.
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { escapeHtml } from "./utils.js";
|
|
|
|
describe("escapeHtml", () => {
|
|
it("escapes ampersand", () => {
|
|
expect(escapeHtml("a & b")).toBe("a & b");
|
|
});
|
|
|
|
it("escapes less-than and greater-than", () => {
|
|
expect(escapeHtml("<script>")).toBe("<script>");
|
|
});
|
|
|
|
it("escapes double quote", () => {
|
|
expect(escapeHtml('say "hello"')).toBe("say "hello"");
|
|
});
|
|
|
|
it("escapes single quote", () => {
|
|
expect(escapeHtml("it's")).toBe("it's");
|
|
});
|
|
|
|
it("escapes all special chars together", () => {
|
|
expect(escapeHtml('&<>"\'')).toBe("&<>"'");
|
|
});
|
|
|
|
it("returns unchanged string when no special chars", () => {
|
|
expect(escapeHtml("plain text")).toBe("plain text");
|
|
});
|
|
|
|
it("handles empty string", () => {
|
|
expect(escapeHtml("")).toBe("");
|
|
});
|
|
|
|
it("coerces non-string to string", () => {
|
|
expect(escapeHtml(123)).toBe("123");
|
|
expect(escapeHtml(null)).toBe("null");
|
|
expect(escapeHtml(undefined)).toBe("undefined");
|
|
});
|
|
});
|