chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -2,128 +2,62 @@ import { formatDownloadTitle } from "../../src/services/utils.ts";
import { describe, it, execute, expect } from "../mini_test.ts";
const testCases: [fnValue: Parameters<typeof formatDownloadTitle>, expectedValue: ReturnType<typeof formatDownloadTitle>][] = [
// empty fileName tests
[
["", "text", ""],
"untitled.html"
],
// empty fileName tests
[["", "text", ""], "untitled.html"],
[
["", "canvas", ""],
"untitled.json"
],
[["", "canvas", ""], "untitled.json"],
[
["", null, ""],
"untitled"
],
[["", null, ""], "untitled"],
// json extension from type tests
[
["test_file", "canvas", ""],
"test_file.json"
],
// json extension from type tests
[["test_file", "canvas", ""], "test_file.json"],
[
["test_file", "relationMap", ""],
"test_file.json"
],
[["test_file", "relationMap", ""], "test_file.json"],
[
["test_file", "search", ""],
"test_file.json"
],
[["test_file", "search", ""], "test_file.json"],
// extension based on mime type
[
["test_file", null, "text/csv"],
"test_file.csv"
],
// extension based on mime type
[["test_file", null, "text/csv"], "test_file.csv"],
[
["test_file_wo_ext", "image", "image/svg+xml"],
"test_file_wo_ext.svg"
],
[["test_file_wo_ext", "image", "image/svg+xml"], "test_file_wo_ext.svg"],
[
["test_file_wo_ext", "file", "application/json"],
"test_file_wo_ext.json"
],
[["test_file_wo_ext", "file", "application/json"], "test_file_wo_ext.json"],
[
["test_file_w_fake_ext.ext", "image", "image/svg+xml"],
"test_file_w_fake_ext.ext.svg"
],
[["test_file_w_fake_ext.ext", "image", "image/svg+xml"], "test_file_w_fake_ext.ext.svg"],
[
["test_file_w_correct_ext.svg", "image", "image/svg+xml"],
"test_file_w_correct_ext.svg"
],
[["test_file_w_correct_ext.svg", "image", "image/svg+xml"], "test_file_w_correct_ext.svg"],
[
["test_file_w_correct_ext.svgz", "image", "image/svg+xml"],
"test_file_w_correct_ext.svgz"
],
[["test_file_w_correct_ext.svgz", "image", "image/svg+xml"], "test_file_w_correct_ext.svgz"],
[
["test_file.zip", "file", "application/zip"],
"test_file.zip"
],
[["test_file.zip", "file", "application/zip"], "test_file.zip"],
[
["test_file", "file", "application/zip"],
"test_file.zip"
],
[["test_file", "file", "application/zip"], "test_file.zip"],
// application/octet-stream tests
[
["test_file", "file", "application/octet-stream"],
"test_file"
],
// application/octet-stream tests
[["test_file", "file", "application/octet-stream"], "test_file"],
[
["test_file.zip", "file", "application/octet-stream"],
"test_file.zip"
],
[["test_file.zip", "file", "application/octet-stream"], "test_file.zip"],
[
["test_file.unknown", null, "application/octet-stream"],
"test_file.unknown"
],
[["test_file.unknown", null, "application/octet-stream"], "test_file.unknown"],
// sanitized filename tests
[
["test/file", null, "application/octet-stream"],
"testfile"
],
// sanitized filename tests
[["test/file", null, "application/octet-stream"], "testfile"],
[
["test:file.zip", "file", "application/zip"],
"testfile.zip"
],
[["test:file.zip", "file", "application/zip"], "testfile.zip"],
[
[":::", "file", "application/zip"],
".zip"
],
[
[":::a", "file", "application/zip"],
"a.zip"
],
]
[[":::", "file", "application/zip"], ".zip"],
[[":::a", "file", "application/zip"], "a.zip"]
];
describe("utils/formatDownloadTitle unit tests", () => {
testCases.forEach((testCase) => {
return it(`With args '${JSON.stringify(testCase[0])}' it should return '${testCase[1]}'`, () => {
const [value, expected] = testCase;
const actual = formatDownloadTitle(...value);
expect(actual).toEqual(expected);
});
});
});
testCases.forEach(testCase => {
return it(`With args '${JSON.stringify(testCase[0])}' it should return '${testCase[1]}'`, () => {
const [value, expected] = testCase;
const actual = formatDownloadTitle(...value);
expect(actual).toEqual(expected);
})
})
})
execute()
execute();