mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: improve code readability by normalizing whitespace and enhancing comments in tests
This commit is contained in:
@@ -488,8 +488,10 @@ describe("BaseAPI", () => {
|
||||
});
|
||||
|
||||
it("should use DEFAULT_LIMIT when limit is 0 (falsy value fallback)", async () => {
|
||||
// When limit is 0, parseInt("0", 10) returns 0 which is falsy,
|
||||
// so the code falls back to DEFAULT_LIMIT via || operator
|
||||
/*
|
||||
* When limit is 0, parseInt("0", 10) returns 0 which is falsy,
|
||||
* so the code falls back to DEFAULT_LIMIT via || operator
|
||||
*/
|
||||
emptyRequest.query["limit"] = "0";
|
||||
// This should NOT throw since limit=0 is converted to DEFAULT_LIMIT
|
||||
await expect(
|
||||
|
||||
@@ -304,8 +304,12 @@ PARTITION BY (column_ObjectID)
|
||||
/* eslint-enable prettier/prettier */
|
||||
|
||||
// Normalize whitespace for comparison to avoid formatting issues
|
||||
const normalizeWhitespace = (s: string): string => s.replace(/\s+/g, ' ').trim();
|
||||
expect(normalizeWhitespace(statement.query)).toBe(normalizeWhitespace(expectedStatement.query));
|
||||
const normalizeWhitespace = (s: string): string => {
|
||||
return s.replace(/\s+/g, " ").trim();
|
||||
};
|
||||
expect(normalizeWhitespace(statement.query)).toBe(
|
||||
normalizeWhitespace(expectedStatement.query),
|
||||
);
|
||||
expect(statement.query_params).toStrictEqual(
|
||||
expectedStatement.query_params,
|
||||
);
|
||||
|
||||
@@ -2,12 +2,7 @@ import FilePicker from "../../../UI/Components/FilePicker/FilePicker";
|
||||
import ModelAPI from "../../../UI/Utils/ModelAPI/ModelAPI";
|
||||
import { describe, expect, beforeEach, jest } from "@jest/globals";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
import {
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
} from "@testing-library/react";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import HTTPResponse from "../../../Types/API/HTTPResponse";
|
||||
import MimeType from "../../../Types/File/MimeType";
|
||||
import ObjectID from "../../../Types/ObjectID";
|
||||
@@ -68,10 +63,7 @@ const mockCreateResponse: MockCreateResponseFunction = async (
|
||||
return new HTTPResponse(200, fileModel as any, {});
|
||||
};
|
||||
|
||||
type MockFileModelFunction = (
|
||||
file: File,
|
||||
id?: string,
|
||||
) => Promise<FileModel>;
|
||||
type MockFileModelFunction = (file: File, id?: string) => Promise<FileModel>;
|
||||
|
||||
const mockFileModel: MockFileModelFunction = async (
|
||||
file: File,
|
||||
@@ -457,7 +449,7 @@ describe("FilePicker", () => {
|
||||
});
|
||||
|
||||
// Error on arrayBuffer test
|
||||
it('should handle error when file arrayBuffer fails', async () => {
|
||||
it("should handle error when file arrayBuffer fails", async () => {
|
||||
const file: File = mockFile("error-file.png");
|
||||
file.arrayBuffer = getJestMockFunction().mockRejectedValue(
|
||||
new Error("File too large"),
|
||||
|
||||
@@ -402,7 +402,11 @@ describe("API.patch", () => {
|
||||
test("should make a PATCH request", async () => {
|
||||
mockedAxios.mockResolvedValueOnce(createAxiosResponse());
|
||||
|
||||
const url: URL = new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact"));
|
||||
const url: URL = new URL(
|
||||
Protocol.HTTPS,
|
||||
"catfact.ninja",
|
||||
new Route("fact"),
|
||||
);
|
||||
const got: HTTPResponse<JSONObject> = await API.patch({
|
||||
url,
|
||||
data: requestData,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// AI Template definitions for different note types
|
||||
// These templates guide AI generation for various use cases
|
||||
/*
|
||||
* AI Template definitions for different note types
|
||||
* These templates guide AI generation for various use cases
|
||||
*/
|
||||
|
||||
export interface AITemplate {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user