@uxf/core 11.45.0 → 11.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/cookie/cookie.test.d.ts +1 -0
  2. package/cookie/cookie.test.js +68 -0
  3. package/next/query-param.test.d.ts +1 -0
  4. package/next/query-param.test.js +35 -0
  5. package/package.json +1 -1
  6. package/utils/assert-not-nil.test.d.ts +1 -0
  7. package/utils/assert-not-nil.test.js +8 -0
  8. package/utils/copy-to-clipboard.test.d.ts +1 -0
  9. package/utils/copy-to-clipboard.test.js +30 -0
  10. package/utils/file.test.d.ts +1 -0
  11. package/utils/file.test.js +35 -0
  12. package/utils/filter-nullish.test.d.ts +1 -0
  13. package/utils/filter-nullish.test.js +15 -0
  14. package/utils/is-empty.d.ts +3 -1
  15. package/utils/is-empty.js +3 -0
  16. package/utils/is-empty.test.js +5 -4
  17. package/utils/is-nil.test.d.ts +1 -0
  18. package/utils/is-nil.test.js +7 -0
  19. package/utils/is-not-empty.d.ts +3 -1
  20. package/utils/is-not-empty.test.js +5 -4
  21. package/utils/is-not-nil.test.d.ts +1 -0
  22. package/utils/is-not-nil.test.js +7 -0
  23. package/utils/isBrowser.test.d.ts +1 -0
  24. package/utils/isBrowser.test.js +12 -0
  25. package/utils/isServer.test.d.ts +1 -0
  26. package/utils/isServer.test.js +12 -0
  27. package/utils/noop.test.d.ts +1 -0
  28. package/utils/noop.test.js +15 -0
  29. package/utils/resizer.d.ts +2 -2
  30. package/utils/resizer.js +7 -7
  31. package/utils/resizer.test.d.ts +1 -0
  32. package/utils/resizer.test.js +85 -0
  33. package/utils/slugify.test.js +5 -3
  34. package/utils/sort-object-keys.test.d.ts +1 -0
  35. package/utils/sort-object-keys.test.js +65 -0
  36. package/utils/throw-error.test.d.ts +1 -0
  37. package/utils/throw-error.test.js +14 -0
  38. package/utils/trim-trailing-zeros.test.d.ts +1 -0
  39. package/utils/trim-trailing-zeros.test.js +10 -0
  40. package/utils/trimTrailingZeros.js +1 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ describe("Cookie Class", () => {
5
+ const cookieName = "testCookie";
6
+ const cookieValue = "testValue";
7
+ let cookie;
8
+ beforeEach(() => {
9
+ cookie = new index_1.Cookie({
10
+ res: {
11
+ setHeader: jest.fn(),
12
+ getHeader: jest.fn().mockReturnValue([]),
13
+ },
14
+ req: {
15
+ headers: {
16
+ cookie: "",
17
+ },
18
+ },
19
+ });
20
+ });
21
+ it("should create a new Cookie instance without context", () => {
22
+ const cookieInstance = index_1.Cookie.create();
23
+ expect(cookieInstance).toBeInstanceOf(index_1.Cookie);
24
+ // eslint-disable-next-line dot-notation
25
+ expect(cookieInstance["ctx"]).toBeNull();
26
+ });
27
+ it("should create a new Cookie instance with context", () => {
28
+ const mockContext = { req: {}, res: {} };
29
+ const cookieInstance = index_1.Cookie.create(mockContext);
30
+ expect(cookieInstance).toBeInstanceOf(index_1.Cookie);
31
+ // eslint-disable-next-line dot-notation
32
+ expect(cookieInstance["ctx"]).toEqual(mockContext);
33
+ });
34
+ it("should set a cookie correctly", () => {
35
+ cookie.set(cookieName, cookieValue);
36
+ expect(document.cookie).toContain(`${cookieName}=${encodeURIComponent(cookieValue)}`);
37
+ });
38
+ it("should get a cookie value correctly", () => {
39
+ Object.defineProperty(document, "cookie", {
40
+ writable: true,
41
+ value: `${cookieName}=${encodeURIComponent(cookieValue)};`,
42
+ });
43
+ const result = cookie.get(cookieName);
44
+ expect(result).toBe(cookieValue);
45
+ });
46
+ it("should return an empty string if the cookie does not exist", () => {
47
+ const result = cookie.get("nonExistentCookie");
48
+ expect(result).toBe("");
49
+ });
50
+ it("should check if a cookie exists", () => {
51
+ Object.defineProperty(document, "cookie", {
52
+ writable: true,
53
+ value: `${cookieName}=${encodeURIComponent(cookieValue)};`,
54
+ });
55
+ const hasCookie = cookie.has(cookieName);
56
+ expect(hasCookie).toBe(true);
57
+ });
58
+ it("should return false if the cookie does not exist", () => {
59
+ const hasCookie = cookie.has("nonExistentCookie");
60
+ expect(hasCookie).toBe(false);
61
+ });
62
+ it("should delete a cookie", () => {
63
+ cookie.set(cookieName, cookieValue, 3600);
64
+ expect(cookie.has(cookieName)).toBe(true);
65
+ cookie.delete(cookieName);
66
+ expect(cookie.has(cookieName)).toBe(false);
67
+ });
68
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ describe("queryParamToString", () => {
5
+ it("should return the string when a string is passed", () => {
6
+ const result = (0, index_1.queryParamToString)("test");
7
+ expect(result).toBe("test");
8
+ });
9
+ it("should return an empty string when undefined is passed", () => {
10
+ const result = (0, index_1.queryParamToString)(undefined);
11
+ expect(result).toBe("");
12
+ });
13
+ it("should return an empty string when an array is passed", () => {
14
+ const result = (0, index_1.queryParamToString)(["test", "jest"]);
15
+ expect(result).toBe("");
16
+ });
17
+ });
18
+ describe("queryParamToNumber", () => {
19
+ it("should return the number when a valid string is passed", () => {
20
+ const result = (0, index_1.queryParamToNumber)("42");
21
+ expect(result).toBe(42);
22
+ });
23
+ it("should return 0 when undefined is passed", () => {
24
+ const result = (0, index_1.queryParamToNumber)(undefined);
25
+ expect(result).toBe(0);
26
+ });
27
+ it("should return 0 when an array is passed", () => {
28
+ const result = (0, index_1.queryParamToNumber)(["42", "8"]);
29
+ expect(result).toBe(0);
30
+ });
31
+ it("should return NaN when an invalid number string is passed", () => {
32
+ const result = (0, index_1.queryParamToNumber)("not a number");
33
+ expect(result).toBe(NaN);
34
+ });
35
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core",
3
- "version": "11.45.0",
3
+ "version": "11.46.0",
4
4
  "description": "UXF Core",
5
5
  "author": "Petr Vejvoda <vejvoda@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/core#readme",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const assert_not_nil_1 = require("./assert-not-nil");
4
+ test("assert-not-nil", () => {
5
+ expect(() => (0, assert_not_nil_1.assertNotNil)(null)).toThrow("Value is nil.");
6
+ expect(() => (0, assert_not_nil_1.assertNotNil)(undefined, "Test")).toThrow("Test");
7
+ ["", true, false, NaN, 0, [], {}].map((value) => expect(() => (0, assert_not_nil_1.assertNotNil)(value)).not.toThrow("Value is nil."));
8
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const copy_to_clipboard_1 = require("./copy-to-clipboard");
4
+ describe("Clipboard Functions", () => {
5
+ beforeEach(() => {
6
+ document.execCommand = jest.fn();
7
+ Object.defineProperty(navigator, "clipboard", {
8
+ value: {
9
+ writeText: jest.fn(),
10
+ },
11
+ writable: true,
12
+ });
13
+ });
14
+ it("should copy text using navigator.clipboard when supported", async () => {
15
+ const text = "Hello, World!";
16
+ const result = await (0, copy_to_clipboard_1.copyToClipboard)(text);
17
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith(text);
18
+ expect(result).toBe(true);
19
+ });
20
+ it("should return false when clipboard.writeText throws an error during fallback", async () => {
21
+ navigator.clipboard.writeText = jest.fn().mockRejectedValue(new Error("Clipboard API not supported"));
22
+ document.execCommand = jest.fn().mockImplementation(() => {
23
+ throw new Error("Copy failed");
24
+ });
25
+ const consoleErrorMock = jest.spyOn(console, "error").mockImplementation(() => ({}));
26
+ const result = await (0, copy_to_clipboard_1.copyToClipboard)("Hello, World!");
27
+ expect(result).toBe(false);
28
+ consoleErrorMock.mockRestore();
29
+ });
30
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const file_1 = require("./file");
4
+ test("file", () => {
5
+ expect((0, file_1.getFileUrl)({
6
+ uuid: "",
7
+ namespace: undefined,
8
+ extension: "",
9
+ })).toBe("/upload///.");
10
+ expect((0, file_1.getFileUrl)({
11
+ uuid: "",
12
+ namespace: undefined,
13
+ extension: "extension",
14
+ })).toBe("/upload///.extension");
15
+ expect((0, file_1.getFileUrl)({
16
+ uuid: "",
17
+ namespace: "namespace",
18
+ extension: "extension",
19
+ })).toBe("/upload/namespace///.extension");
20
+ expect((0, file_1.getFileUrl)({
21
+ uuid: "uuid",
22
+ namespace: null,
23
+ extension: "extension",
24
+ })).toBe("/upload/u/u/uuid.extension");
25
+ expect((0, file_1.getFileUrl)({
26
+ uuid: "u",
27
+ namespace: undefined,
28
+ extension: "",
29
+ })).toBe("/upload/u//u.");
30
+ expect((0, file_1.getFileUrl)({
31
+ uuid: "uuid",
32
+ namespace: "namespace",
33
+ extension: "extension",
34
+ })).toBe("/upload/namespace/u/u/uuid.extension");
35
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const filter_nullish_1 = require("./filter-nullish");
4
+ test("filter-nullish", () => {
5
+ expect((0, filter_nullish_1.filterNullish)([undefined, null, 0, NaN, "", true, false, [], {}])).toStrictEqual([
6
+ 0,
7
+ NaN,
8
+ "",
9
+ true,
10
+ false,
11
+ [],
12
+ {},
13
+ ]);
14
+ expect((0, filter_nullish_1.filterNullish)([])).toStrictEqual([]);
15
+ });
@@ -1 +1,3 @@
1
- export declare function isEmpty(value: any[] | string): boolean;
1
+ export declare function isEmpty(value: any[] | {
2
+ [key: string]: any;
3
+ } | string): boolean;
package/utils/is-empty.js CHANGED
@@ -5,5 +5,8 @@ function isEmpty(value) {
5
5
  if (Array.isArray(value)) {
6
6
  return value.length === 0;
7
7
  }
8
+ else if (value && typeof value === "object") {
9
+ return Object.keys(value).length === 0;
10
+ }
8
11
  return value === "";
9
12
  }
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition,@typescript-eslint/ban-ts-comment */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const is_empty_1 = require("./is-empty");
4
5
  test("is-empty", () => {
5
- expect((0, is_empty_1.isEmpty)(["1"])).toBeFalsy();
6
- expect((0, is_empty_1.isEmpty)([])).toBeTruthy();
7
- expect((0, is_empty_1.isEmpty)("not-empty")).toBeFalsy();
8
- expect((0, is_empty_1.isEmpty)("")).toBeTruthy();
6
+ [["1"], { not: "empty" }, "not-empty"].map((value) => expect((0, is_empty_1.isEmpty)(value)).toBeFalsy());
7
+ [[], {}, ""].map((value) => expect((0, is_empty_1.isEmpty)(value)).toBeTruthy());
8
+ // @ts-expect-error
9
+ [0, null, undefined, true, false].map((value) => expect((0, is_empty_1.isEmpty)(value)).toBeFalsy());
9
10
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const is_nil_1 = require("./is-nil");
4
+ test("is-nil", () => {
5
+ [null, undefined].map((value) => expect((0, is_nil_1.isNil)(value)).toBeTruthy());
6
+ ["", true, false, NaN, 0, [], {}].map((value) => expect((0, is_nil_1.isNil)(value)).toBeFalsy());
7
+ });
@@ -1 +1,3 @@
1
- export declare function isNotEmpty(value: any[] | string): boolean;
1
+ export declare function isNotEmpty(value: any[] | {
2
+ [key: string]: any;
3
+ } | string): boolean;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition,@typescript-eslint/ban-ts-comment */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const is_not_empty_1 = require("./is-not-empty");
4
5
  test("is-not-empty", () => {
5
- expect((0, is_not_empty_1.isNotEmpty)(["1"])).toBeTruthy();
6
- expect((0, is_not_empty_1.isNotEmpty)([])).toBeFalsy();
7
- expect((0, is_not_empty_1.isNotEmpty)("not-empty")).toBeTruthy();
8
- expect((0, is_not_empty_1.isNotEmpty)("")).toBeFalsy();
6
+ [["1"], { not: "empty" }, "not-empty"].map((value) => expect((0, is_not_empty_1.isNotEmpty)(value)).toBeTruthy());
7
+ [[], {}, ""].map((value) => expect((0, is_not_empty_1.isNotEmpty)(value)).toBeFalsy());
8
+ // @ts-expect-error
9
+ [0, null, undefined, true, false].map((value) => expect((0, is_not_empty_1.isNotEmpty)(value)).toBeTruthy());
9
10
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const is_not_nil_1 = require("./is-not-nil");
4
+ test("is-not-nil", () => {
5
+ ["", true, false, NaN, 0, [], {}].map((value) => expect((0, is_not_nil_1.isNotNil)(value)).toBeTruthy());
6
+ [null, undefined].map((value) => expect((0, is_not_nil_1.isNotNil)(value)).toBeFalsy());
7
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const isBrowser_1 = require("./isBrowser");
4
+ test("isBrowser", () => {
5
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
6
+ if (window === undefined) {
7
+ expect(isBrowser_1.isBrowser).toBeFalsy();
8
+ }
9
+ else {
10
+ expect(isBrowser_1.isBrowser).toBeTruthy();
11
+ }
12
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const isBrowser_1 = require("./isBrowser");
4
+ const isServer_1 = require("./isServer");
5
+ test("isServer", () => {
6
+ if (isBrowser_1.isBrowser) {
7
+ expect(isServer_1.isServer).toBeFalsy();
8
+ }
9
+ else {
10
+ expect(isServer_1.isServer).toBeTruthy();
11
+ }
12
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const noop_1 = require("./noop");
4
+ describe("noop function", () => {
5
+ it("should return undefined when called", () => {
6
+ const result = (0, noop_1.noop)();
7
+ expect(result).toBeUndefined();
8
+ });
9
+ it("should not call any other function", () => {
10
+ const spy = jest.fn();
11
+ spy();
12
+ expect(spy).toHaveBeenCalled();
13
+ expect((0, noop_1.noop)()).toBeUndefined();
14
+ });
15
+ });
@@ -12,14 +12,14 @@ export type StaticImageData = {
12
12
  blurDataURL?: string;
13
13
  };
14
14
  export type ImageSource = ImageResponse | StaticImageData | string;
15
- declare const fitMapper: {
15
+ export declare const fitMapper: {
16
16
  cover: string;
17
17
  fill: string;
18
18
  contain: string;
19
19
  inside: string;
20
20
  outside: string;
21
21
  };
22
- declare const positionMapper: {
22
+ export declare const positionMapper: {
23
23
  attention: string;
24
24
  bottom: string;
25
25
  centre: string;
package/utils/resizer.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resizerImageUrl = void 0;
3
+ exports.resizerImageUrl = exports.positionMapper = exports.fitMapper = void 0;
4
4
  exports.resizerGetDefaultConfig = resizerGetDefaultConfig;
5
- const fitMapper = {
5
+ exports.fitMapper = {
6
6
  cover: "cv",
7
7
  fill: "f",
8
8
  contain: "cn",
9
9
  inside: "in",
10
10
  outside: "out",
11
11
  };
12
- const positionMapper = {
12
+ exports.positionMapper = {
13
13
  attention: "a",
14
14
  bottom: "b",
15
15
  centre: "c",
@@ -39,8 +39,8 @@ const resizerStaticImageUrl = (src, width = "auto", height = "auto", props = {},
39
39
  const directory = [
40
40
  width === "auto" ? "x" : width,
41
41
  height === "auto" ? "x" : height,
42
- fitMapper[fit],
43
- positionMapper[position],
42
+ exports.fitMapper[fit],
43
+ exports.positionMapper[position],
44
44
  background === "transparent" ? backgroundMapper[background] : background,
45
45
  trim === "not-trim" ? trimMapper[trim] : trim,
46
46
  (_a = props.quality) !== null && _a !== void 0 ? _a : "x",
@@ -60,8 +60,8 @@ const resizerImageUrl = (source, width = "auto", height = "auto", props = {}, ve
60
60
  source.uuid,
61
61
  width === "auto" ? "x" : width,
62
62
  height === "auto" ? "x" : height,
63
- fitMapper[fit],
64
- positionMapper[position],
63
+ exports.fitMapper[fit],
64
+ exports.positionMapper[position],
65
65
  background === "transparent" ? backgroundMapper[background] : background,
66
66
  trim === "not-trim" ? trimMapper[trim] : trim,
67
67
  (_b = props.quality) !== null && _b !== void 0 ? _b : "x",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const resizer_1 = require("./resizer");
4
+ describe("resizerGetDefaultConfig", () => {
5
+ it("should return a valid URL for a StaticImageData source", () => {
6
+ const staticImage = {
7
+ src: "http://example.com/image.jpg",
8
+ height: 800,
9
+ width: 600,
10
+ };
11
+ const url = (0, resizer_1.resizerImageUrl)(staticImage, undefined, undefined, {
12
+ fit: "cover",
13
+ position: "bottom",
14
+ background: "transparent",
15
+ trim: "not-trim",
16
+ toFormat: "avif",
17
+ quality: 1,
18
+ });
19
+ expect(url).toBe("/generated/static/x_x_cv_b_t_nt_1/1http://example.com/image.jpg.avif");
20
+ });
21
+ it("should return a valid URL for an ImageResponse source", () => {
22
+ const imageResponse = {
23
+ uuid: "12345678",
24
+ namespace: "images",
25
+ extension: "jpg",
26
+ };
27
+ const url = (0, resizer_1.resizerImageUrl)(imageResponse, 400, 300, { fit: "contain", quality: 80 });
28
+ expect(url).toBe("/generated/images/1/2/12345678_400_300_cn_c_FFF_nt_80_jpg.jpg");
29
+ });
30
+ it("should return a valid URL for a string source", () => {
31
+ const url = (0, resizer_1.resizerImageUrl)("http://example.com/image.png", 250, 250, { toFormat: "webp" });
32
+ expect(url).toBe("/generated/static/250_250_cv_c_FFF_nt_x/1http://example.com/image.png.webp");
33
+ });
34
+ it("should return undefined for null or undefined source", () => {
35
+ expect((0, resizer_1.resizerImageUrl)(null)).toBeUndefined();
36
+ expect((0, resizer_1.resizerImageUrl)(undefined)).toBeUndefined();
37
+ expect((0, resizer_1.resizerImageUrl)("")).toBeUndefined();
38
+ });
39
+ it("should use default values for missing props", () => {
40
+ const imageResponse = {
41
+ uuid: "abcdef12",
42
+ extension: "png",
43
+ };
44
+ const url = (0, resizer_1.resizerImageUrl)(imageResponse);
45
+ expect(url).toBe("/generated/undefined/a/b/abcdef12_x_x_cv_c_FFF_nt_x_png.png");
46
+ });
47
+ it("should map fit values correctly", () => {
48
+ const imageResponse = {
49
+ uuid: "fit-test",
50
+ namespace: "images",
51
+ extension: "jpg",
52
+ };
53
+ Object.entries(resizer_1.fitMapper).forEach(([key, value]) => {
54
+ const url = (0, resizer_1.resizerImageUrl)(imageResponse, 300, 200, { fit: key });
55
+ expect(url).toContain(`_${value}`);
56
+ });
57
+ });
58
+ it("should map position values correctly", () => {
59
+ const imageResponse = {
60
+ uuid: "position-test",
61
+ namespace: "images",
62
+ extension: "jpg",
63
+ };
64
+ Object.entries(resizer_1.positionMapper).forEach(([key, value]) => {
65
+ const url = (0, resizer_1.resizerImageUrl)(imageResponse, 300, 200, { position: key });
66
+ expect(url).toContain(`_${value}`);
67
+ });
68
+ });
69
+ it("should return the default configuration based on generatedFilesUrl and staticFilesUrl", () => {
70
+ const generatedFilesUrl = "http://example.com/generated";
71
+ const staticFilesUrl = "http://example.com/static";
72
+ const expectedConfig = [
73
+ {
74
+ route: "/generated/static/:width(\\d+|x)_:height(\\d+|x)_:fit([a-z]+)_:position([a-z]+)_:background([a-z]+)_:trim([a-z]+)_:quality(\\d+|x)/:version/:filename(*).:extension.:toFormat",
75
+ source: `${staticFilesUrl}/:filename+.:extension`,
76
+ },
77
+ {
78
+ route: "/generated/:namespace/:p1/:p2/:filename([a-f0-9\\-]+)_:width(\\d+|x)_:height(\\d+|x)_:fit([a-z]+)_:position([a-z]+)_:background([a-z]+)_:trim([a-z]+)_:quality(\\d+|x)_:extension.:toFormat",
79
+ source: `${generatedFilesUrl}/upload/:namespace/:p1/:p2/:filename.:extension`,
80
+ },
81
+ ];
82
+ const result = (0, resizer_1.resizerGetDefaultConfig)(generatedFilesUrl, staticFilesUrl);
83
+ expect(result).toEqual(expectedConfig);
84
+ });
85
+ });
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const slugify_1 = require("./slugify");
4
4
  test("slugify", () => {
5
- expect((0, slugify_1.slugify)("Nějaký název")).toBe("nejaky-nazev");
6
- expect((0, slugify_1.slugify)("8 hrozných")).toBe("8-hroznych");
7
- expect((0, slugify_1.slugify)("Osm hrozných")).toBe("osm-hroznych");
5
+ expect((0, slugify_1.slugify)(" Osm hrozných ")).toBe("osm-hroznych");
6
+ expect((0, slugify_1.slugify)("Osm & hrozných")).toBe("osm-and-hroznych");
7
+ expect((0, slugify_1.slugify)("osm---hroznych")).toBe("osm-hroznych");
8
+ expect((0, slugify_1.slugify)("Osm hrozných.")).toBe("osm-hroznych");
9
+ expect((0, slugify_1.slugify)("àáäâãåăæąçćčđďèéěėëêęǵḧìíïîįłḿǹńňñòóöôœøṕŕřßśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;")).toBe("aaaaaaaaacccddeeeeeeeghiiiiilmnnnnooooooprrssssttuuuuuuuuuwxyyzzz");
8
10
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sort_object_keys_1 = require("./sort-object-keys");
4
+ describe("sortObjectKeys", () => {
5
+ it("should sort object keys in alphabetical order", () => {
6
+ const input = {
7
+ b: "banana",
8
+ a: "apple",
9
+ d: "date",
10
+ c: "cherry",
11
+ };
12
+ const expectedOutput = {
13
+ a: "apple",
14
+ b: "banana",
15
+ c: "cherry",
16
+ d: "date",
17
+ };
18
+ expect((0, sort_object_keys_1.sortObjectKeys)(input)).toEqual(expectedOutput);
19
+ });
20
+ it("should sort nested object keys", () => {
21
+ const input = {
22
+ b: {
23
+ d: "date",
24
+ c: "cherry",
25
+ },
26
+ a: "apple",
27
+ c: "cat",
28
+ };
29
+ const expectedOutput = {
30
+ a: "apple",
31
+ b: {
32
+ c: "cherry",
33
+ d: "date",
34
+ },
35
+ c: "cat",
36
+ };
37
+ expect((0, sort_object_keys_1.sortObjectKeys)(input)).toEqual(expectedOutput);
38
+ });
39
+ it("should handle empty objects", () => {
40
+ const input = {};
41
+ const expectedOutput = {};
42
+ expect((0, sort_object_keys_1.sortObjectKeys)(input)).toEqual(expectedOutput);
43
+ });
44
+ it("should handle null values and functions gracefully", () => {
45
+ const input = { s: 1, b: [], d: {}, c: "string", g: () => "function" };
46
+ const expectedOutput = {
47
+ b: {},
48
+ c: "string",
49
+ d: {},
50
+ g: {},
51
+ s: {},
52
+ };
53
+ expect((0, sort_object_keys_1.sortObjectKeys)(input)).toEqual(expect.objectContaining(expectedOutput));
54
+ });
55
+ it("should throw an error for object with null and undefined", () => {
56
+ const input = { a: [null], b: null, c: undefined };
57
+ expect(() => (0, sort_object_keys_1.sortObjectKeys)(input)).toThrow();
58
+ });
59
+ it("should throw an error for non-object types", () => {
60
+ const inputs = [null, undefined];
61
+ inputs.forEach((input) => {
62
+ expect(() => (0, sort_object_keys_1.sortObjectKeys)(input)).toThrow();
63
+ });
64
+ });
65
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const throw_error_1 = require("./throw-error");
4
+ describe("throwError", () => {
5
+ it("should throw an error with the provided message", () => {
6
+ const message = "This is an error message";
7
+ expect(() => (0, throw_error_1.throwError)(message)).toThrow(Error);
8
+ expect(() => (0, throw_error_1.throwError)(message)).toThrow(message);
9
+ });
10
+ it("should throw an error without a message", () => {
11
+ expect(() => (0, throw_error_1.throwError)()).toThrow(Error);
12
+ expect(() => (0, throw_error_1.throwError)()).toThrow();
13
+ });
14
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const trimTrailingZeros_1 = require("./trimTrailingZeros");
4
+ test("trimTrailingZeros", () => {
5
+ expect((0, trimTrailingZeros_1.trimTrailingZeros)("1.0000")).toBe("1");
6
+ expect((0, trimTrailingZeros_1.trimTrailingZeros)("1.")).toBe("1.");
7
+ expect((0, trimTrailingZeros_1.trimTrailingZeros)("0")).toBe("0");
8
+ expect((0, trimTrailingZeros_1.trimTrailingZeros)("100")).toBe("100");
9
+ expect((0, trimTrailingZeros_1.trimTrailingZeros)("test .0")).toBe("test ");
10
+ });
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.trimTrailingZeros = trimTrailingZeros;
4
4
  function trimTrailingZeros(value) {
5
- return value.replace(/\.?0+$/, "");
5
+ return value.includes(".") ? value.replace(/\.?0+$/, "") : value;
6
6
  }