@maz-ui/utils 4.0.0-beta.7 → 4.0.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 (49) hide show
  1. package/README.md +181 -0
  2. package/dist/helpers/index.js +58 -42
  3. package/dist/helpers/kebabCase.js +6 -0
  4. package/dist/helpers/normalizeString.js +31 -8
  5. package/dist/helpers/pascalCase.js +16 -0
  6. package/dist/helpers/snakeCase.js +6 -0
  7. package/dist/index.js +54 -50
  8. package/dist/types/helpers/index.d.ts +8 -0
  9. package/dist/types/helpers/kebabCase.d.ts +1 -0
  10. package/dist/types/helpers/normalizeString.d.ts +6 -0
  11. package/dist/types/helpers/snakeCase.d.ts +1 -0
  12. package/dist/types/index.d.ts +0 -1
  13. package/package.json +11 -23
  14. package/dist/chunks/chunk-hooks.DXGlb1Dd.js +0 -2471
  15. package/dist/chunks/magic-string.es.BQ9KnLz-.js +0 -659
  16. package/dist/formatters/__tests__/capitalize.spec.js +0 -10
  17. package/dist/formatters/__tests__/currency.spec.js +0 -24
  18. package/dist/formatters/__tests__/date.spec.js +0 -20
  19. package/dist/formatters/__tests__/number.spec.js +0 -16
  20. package/dist/formatters/__tests__/telephone.spec.js +0 -11
  21. package/dist/formatters/index.js +0 -14
  22. package/dist/formatters/pascalCase.js +0 -8
  23. package/dist/helpers/__tests__/NormalizeString.spec.js +0 -43
  24. package/dist/helpers/__tests__/ScriptLoader.spec.js +0 -67
  25. package/dist/helpers/__tests__/SwipeHandler.spec.js +0 -54
  26. package/dist/helpers/__tests__/checkAvailability.spec.js +0 -46
  27. package/dist/helpers/__tests__/countryCodeToUnicodeFlag.spec.js +0 -16
  28. package/dist/helpers/__tests__/debounceId.spec.js +0 -16
  29. package/dist/helpers/__tests__/debouneCallback.spec.js +0 -12
  30. package/dist/helpers/__tests__/isEqual.spec.js +0 -46
  31. package/dist/helpers/__tests__/isStandaloneMode.spec.js +0 -8586
  32. package/dist/helpers/__tests__/sleep.spec.js +0 -16
  33. package/dist/helpers/__tests__/throttle.spec.js +0 -43
  34. package/dist/helpers/__tests__/throttleId.spec.js +0 -22
  35. package/dist/helpers/__tests__/userVisibility.spec.js +0 -58
  36. package/dist/types/formatters/index.d.ts +0 -6
  37. /package/dist/{formatters → helpers}/camelCase.js +0 -0
  38. /package/dist/{formatters → helpers}/capitalize.js +0 -0
  39. /package/dist/{formatters → helpers}/formatCurrency.js +0 -0
  40. /package/dist/{formatters → helpers}/formatDate.js +0 -0
  41. /package/dist/{formatters → helpers}/formatNumber.js +0 -0
  42. /package/dist/{formatters → helpers}/formatPhoneNumber.js +0 -0
  43. /package/dist/types/{formatters → helpers}/camelCase.d.ts +0 -0
  44. /package/dist/types/{formatters → helpers}/capitalize.d.ts +0 -0
  45. /package/dist/types/{formatters → helpers}/formatCurrency.d.ts +0 -0
  46. /package/dist/types/{formatters → helpers}/formatDate.d.ts +0 -0
  47. /package/dist/types/{formatters → helpers}/formatNumber.d.ts +0 -0
  48. /package/dist/types/{formatters → helpers}/formatPhoneNumber.d.ts +0 -0
  49. /package/dist/types/{formatters → helpers}/pascalCase.d.ts +0 -0
@@ -1,20 +0,0 @@
1
- import { formatDate as t } from "../formatDate.js";
2
- describe("formatDate", () => {
3
- it("formats a date string as a short date", () => {
4
- expect(t("2022-01-01", "en-US")).toEqual("Jan 1, 2022");
5
- }), it("formats a Date object as a short date", () => {
6
- expect(t(/* @__PURE__ */ new Date("2022-01-01"), "en-US")).toEqual("Jan 1, 2022");
7
- }), it("throws an error if the locale is not provided", () => {
8
- expect(() => t("2022-01-01", void 0)).toThrow(
9
- "[maz-ui](FilterDate) The `locale` attribute is required."
10
- );
11
- }), it("throws an error if the locale is not a string", () => {
12
- expect(() => t("2022-01-01", 123)).toThrow(
13
- "[maz-ui](FilterDate) The `locale` attribute must be a string."
14
- );
15
- }), it("throws an error if the date is invalid", () => {
16
- expect(() => t("invalid date", "en-US")).toThrow(
17
- "[maz-ui](FilterDate) RangeError: Invalid time value"
18
- );
19
- });
20
- });
@@ -1,16 +0,0 @@
1
- import { formatNumber as t } from "../formatNumber.js";
2
- describe("formatNumber", () => {
3
- it("should return the formatted number with default options", () => {
4
- const r = t(123456.789, "en-US", { maximumFractionDigits: 2 });
5
- expect(r).toBe("123,456.79");
6
- }), it("should return the formatted number with custom options", () => {
7
- const r = t(123456.789, "en-US", { minimumFractionDigits: 3 });
8
- expect(r).toBe("123,456.789");
9
- }), it("should throw an error if the `number` argument is not provided", () => {
10
- expect(() => t(void 0, "en-US")).toThrow(TypeError);
11
- }), it("should throw an error if the `locale` argument is not provided", () => {
12
- expect(() => t(123456.789, void 0)).toThrow(TypeError);
13
- }), it("should throw an error if the `locale` argument is not a string", () => {
14
- expect(() => t(123456.789, 123)).toThrow(TypeError);
15
- });
16
- });
@@ -1,11 +0,0 @@
1
- import { formatPhoneNumber as r } from "../formatPhoneNumber.js";
2
- import { i as o } from "../../chunks/chunk-hooks.DXGlb1Dd.js";
3
- o("should format a telephone number", () => {
4
- expect(r("+15551234567")).toEqual("+1 555 123 4567");
5
- });
6
- o("should return the original input if it is not a valid telephone number", () => {
7
- expect(r("123")).toEqual("123");
8
- });
9
- o("should throw an error if the input is falsy", () => {
10
- expect(() => r(null)).toThrowError(TypeError), expect(() => r(void 0)).toThrowError(TypeError), expect(() => r("")).toThrowError(TypeError);
11
- });
@@ -1,14 +0,0 @@
1
- import { camelCase as e } from "./camelCase.js";
2
- import { capitalize as m } from "./capitalize.js";
3
- import { formatCurrency as f } from "./formatCurrency.js";
4
- import { formatDate as x } from "./formatDate.js";
5
- import { formatNumber as l } from "./formatNumber.js";
6
- import { pascalCase as C } from "./pascalCase.js";
7
- export {
8
- e as camelCase,
9
- m as capitalize,
10
- f as formatCurrency,
11
- x as formatDate,
12
- l as formatNumber,
13
- C as pascalCase
14
- };
@@ -1,8 +0,0 @@
1
- import { camelCase as r } from "./camelCase.js";
2
- import { capitalize as e } from "./capitalize.js";
3
- function i(a) {
4
- return e(r(a));
5
- }
6
- export {
7
- i as pascalCase
8
- };
@@ -1,43 +0,0 @@
1
- import { normalizeString as e } from "../normalizeString.js";
2
- describe("normalizeString", () => {
3
- it("should normalize accents by default", () => {
4
- expect(e("áéíóú")).toBe("aeiou");
5
- }), it("should remove accents based on options", () => {
6
- expect(e("áéíóú", { removeAccents: !1 })).toBe("áéíóú");
7
- }), it("should handle case sensitivity based on options", () => {
8
- expect(e("AbCde", { caseSensitive: !0 })).toBe("AbCde"), expect(e("AbCde", { caseSensitive: !1 })).toBe("abcde");
9
- }), it("should replace spaces with dashes based on options", () => {
10
- expect(e("a b c")).toBe("a-b-c");
11
- }), it("should remove special characters based on options", () => {
12
- const o = { removeSpecialCharacters: !0 };
13
- expect(e("a&b@c", o)).toBe("abc");
14
- }), it("should handle special characters", () => {
15
- expect(
16
- e("!@#$%^&*()_+=[]{}|;':,.<>?", {
17
- removeSpecialCharacters: !0
18
- })
19
- ).toBe("");
20
- }), it("should remove numbers based on options", () => {
21
- const o = { removeNumbers: !0 };
22
- expect(e("a1b2c3", o)).toBe("abc");
23
- }), it("should normalize spaces based on options", () => {
24
- expect(e("a b c")).toBe("a-b-c");
25
- }), it("should normalize the string with custom normalization forms based on options", () => {
26
- const o = { customNormalizationForms: ["NFKC"] };
27
- expect(e("ffi", o)).toBe("ffi");
28
- }), it("should trim leading and trailing whitespaces based on options", () => {
29
- expect(e(" abc ")).toBe("abc");
30
- }), it("should handle various combinations of options", () => {
31
- const o = {
32
- removeAccents: !0,
33
- caseSensitive: !1,
34
- replaceSpaces: !0,
35
- removeSpecialCharacters: !0,
36
- trim: !0,
37
- normalizeSpaces: !0,
38
- removeNumbers: !0,
39
- customNormalizationForms: ["NFC", "NFKD"]
40
- };
41
- expect(e("Áé 123 ñ", o)).toBe("ae--n");
42
- });
43
- });
@@ -1,67 +0,0 @@
1
- import { ScriptLoader as i } from "../scriptLoader.js";
2
- describe("given ScriptLoader class", () => {
3
- let t, o;
4
- beforeEach(() => {
5
- t = {
6
- createElement: vi.fn(),
7
- head: {
8
- append: vi.fn(),
9
- querySelector: vi.fn(),
10
- querySelectorAll: vi.fn()
11
- }
12
- }, o = {}, vi.stubGlobal("document", t), vi.stubGlobal("window", o);
13
- }), afterEach(() => {
14
- vi.resetAllMocks();
15
- }), describe("when creating a new instance", () => {
16
- it("then it should throw an error if src is not provided", () => {
17
- expect(() => new i({ identifier: "test" })).toThrow('[ScriptLoader]: You should provide the attribut "src"');
18
- }), it("then it should throw an error if identifier is not provided", () => {
19
- expect(() => new i({ src: "https://example.com/script.js" })).toThrow('[ScriptLoader]: You should provide the attribut "identifier"');
20
- }), it("then it should create an instance with default options", () => {
21
- const r = new i({ src: "https://example.com/script.js", identifier: "test" });
22
- expect(r).toBeInstanceOf(i);
23
- });
24
- }), describe("when calling load method", () => {
25
- let r;
26
- beforeEach(() => {
27
- r = new i({ src: "https://example.com/script.js", identifier: "test" });
28
- }), describe("and the script is already loaded", () => {
29
- it("then it should resolve with the existing script", async () => {
30
- o.test = { type: "load" }, t.head.querySelectorAll.mockReturnValue([{}]);
31
- const e = await r.load();
32
- expect(e).toBeDefined();
33
- });
34
- }), describe("and the script is not loaded", () => {
35
- it("then it should inject the script", async () => {
36
- const e = {
37
- addEventListener: vi.fn((n, c) => {
38
- n === "load" && c({ type: "load" });
39
- }),
40
- dataset: {}
41
- };
42
- t.createElement.mockReturnValue(e), t.head.querySelectorAll.mockReturnValue([]);
43
- const a = await r.load();
44
- expect(a).toEqual({ type: "load" }), expect(t.createElement).toHaveBeenCalledWith("script"), expect(t.head.append).toHaveBeenCalledWith(e);
45
- }), it("then it should handle script load errors", async () => {
46
- const e = {
47
- addEventListener: vi.fn((a, n) => {
48
- a === "error" && n(new Error("Script load failed"));
49
- }),
50
- dataset: {}
51
- };
52
- t.createElement.mockReturnValue(e), t.head.querySelectorAll.mockReturnValue([]), await expect(r.load()).rejects.toThrow("[ScriptLoader](injectScript) Script load failed");
53
- });
54
- });
55
- }), describe("when calling removeTag method", () => {
56
- let r;
57
- beforeEach(() => {
58
- r = new i({ src: "https://example.com/script.js", identifier: "test" });
59
- }), it("then it should remove the tag when given a string identifier", () => {
60
- const e = { remove: vi.fn() };
61
- t.head.querySelector.mockReturnValue(e), r.removeTag("test"), expect(t.head.querySelector).toHaveBeenCalledWith('[data-identifier="test"]'), expect(e.remove).toHaveBeenCalled();
62
- }), it("then it should remove the tag when given an Element", () => {
63
- const e = { remove: vi.fn() };
64
- r.removeTag(e), expect(e.remove).toHaveBeenCalled();
65
- });
66
- });
67
- });
@@ -1,54 +0,0 @@
1
- import { Swipe as n } from "../swipeHandler.js";
2
- describe("given Swipe class", () => {
3
- let t, i;
4
- beforeEach(() => {
5
- t = document.createElement("div"), i = {
6
- element: t
7
- }, vi.spyOn(t, "addEventListener"), vi.spyOn(t, "removeEventListener");
8
- }), describe("when creating a new instance", () => {
9
- it("then it should accept an HTMLElement", () => {
10
- const e = new n(i);
11
- expect(e.element).toBe(t);
12
- }), it("then it should accept a string selector", () => {
13
- const e = vi.spyOn(document, "querySelector").mockReturnValue(t), o = new n({ element: "#test" });
14
- expect(e).toHaveBeenCalledWith("#test"), expect(o.element).toBe(t);
15
- }), it("then it should throw an error if string selector is not found", () => {
16
- vi.spyOn(document, "querySelector").mockReturnValue(null);
17
- const e = vi.spyOn(console, "error").mockImplementation(() => {
18
- });
19
- new n({ element: "#test" }), expect(e).toHaveBeenCalledWith("[maz-ui][SwipeHandler](setElement) String selector for element is not found");
20
- }), it("then it should start immediately if immediate option is true", () => {
21
- new n({ ...i, immediate: !0 }), expect(t.addEventListener).toHaveBeenCalledWith("touchstart", expect.any(Function), { passive: !0 });
22
- });
23
- }), describe("when calling start method", () => {
24
- it("then it should add event listeners", () => {
25
- new n(i).start(), expect(t.addEventListener).toHaveBeenCalledWith("touchstart", expect.any(Function), { passive: !0 }), expect(t.addEventListener).toHaveBeenCalledWith("touchmove", expect.any(Function), { passive: !0 });
26
- }), it("then it should add touchend listener if triggerOnEnd is true", () => {
27
- new n({ ...i, triggerOnEnd: !0 }).start(), expect(t.addEventListener).toHaveBeenCalledWith("touchend", expect.any(Function), { passive: !0 });
28
- }), it("then it should add mousewheel listener if preventDefaultOnMouseWheel is true", () => {
29
- new n({ ...i, preventDefaultOnMouseWheel: !0 }).start(), expect(t.addEventListener).toHaveBeenCalledWith("mousewheel", expect.any(Function), { passive: !1 });
30
- });
31
- }), describe("when calling stop method", () => {
32
- it("then it should remove event listeners", () => {
33
- const e = new n(i);
34
- e.start(), e.stop(), expect(t.removeEventListener).toHaveBeenCalledWith("touchstart", expect.any(Function)), expect(t.removeEventListener).toHaveBeenCalledWith("touchmove", expect.any(Function));
35
- });
36
- }), describe("when handling touch events", () => {
37
- let e, o, s, a;
38
- beforeEach(() => {
39
- e = new n(i), o = new TouchEvent("touchstart", { touches: [{ clientX: 0, clientY: 0 }] }), s = new TouchEvent("touchmove", { touches: [{ clientX: 100, clientY: 50 }] }), a = new TouchEvent("touchend");
40
- }), it("then it should update values on touchstart", () => {
41
- e.start(), t.dispatchEvent(o), expect(e.xStart).toBe(0), expect(e.yStart).toBe(0);
42
- }), it("then it should update values on touchmove", () => {
43
- e.start(), t.dispatchEvent(o), t.dispatchEvent(s), expect(e.xEnd).toBe(100), expect(e.yEnd).toBe(50), expect(e.xDiff).toBe(void 0), expect(e.yDiff).toBe(void 0);
44
- }), it("then it should call onValuesChanged callback when values change", () => {
45
- const c = vi.fn();
46
- e = new n({ ...i, onValuesChanged: c }), e.start(), t.dispatchEvent(o), t.dispatchEvent(s), t.dispatchEvent(s), expect(c).toHaveBeenCalledTimes(1);
47
- }), it("then it should not trigger callbacks if movement is below threshold", () => {
48
- const c = vi.fn();
49
- e = new n({ ...i, onRight: c, threshold: 150 }), e.start(), t.dispatchEvent(o), t.dispatchEvent(s), expect(c).not.toHaveBeenCalled();
50
- }), it("then it should reset values after touch end", () => {
51
- e = new n({ ...i, triggerOnEnd: !0 }), e.start(), t.dispatchEvent(o), t.dispatchEvent(s), t.dispatchEvent(a), expect(e.xStart).toBe(0), expect(e.yStart).toBe(0), expect(e.xEnd).toBe(100), expect(e.yEnd).toBe(50), expect(e.xDiff).toBe(void 0), expect(e.yDiff).toBe(void 0);
52
- });
53
- });
54
- });
@@ -1,46 +0,0 @@
1
- import { checkAvailability as c } from "../checkAvailability.js";
2
- describe("given checkAvailability helper", () => {
3
- beforeEach(() => {
4
- vi.useFakeTimers();
5
- }), it("should call the callback immediately when ref is available", () => {
6
- const a = { value: "test" }, t = vi.fn(() => a), e = vi.fn();
7
- c(t, e), expect(t).toHaveBeenCalledTimes(1), expect(e).toHaveBeenCalledTimes(1), expect(e).toHaveBeenCalledWith(a);
8
- }), it("should retry until ref is available", () => {
9
- const a = { value: "test" }, t = vi.fn().mockReturnValueOnce(null).mockReturnValueOnce(null).mockReturnValue(a), e = vi.fn();
10
- c(t, e), expect(t).toHaveBeenCalledTimes(1), expect(e).not.toHaveBeenCalled(), vi.advanceTimersByTime(100), expect(t).toHaveBeenCalledTimes(2), expect(e).not.toHaveBeenCalled(), vi.advanceTimersByTime(100), expect(t).toHaveBeenCalledTimes(3), expect(e).toHaveBeenCalledTimes(1), expect(e).toHaveBeenCalledWith(a);
11
- }), it("should stop retrying after max attempts", () => {
12
- const a = vi.fn(() => null), t = vi.fn();
13
- c(a, t, { maxAttempts: 5, interval: 50 });
14
- for (let e = 0; e < 5; e++)
15
- vi.advanceTimersByTime(50);
16
- expect(a).toHaveBeenCalledTimes(6), expect(t).not.toHaveBeenCalled();
17
- }), it("should use custom error message when provided", () => {
18
- const a = vi.fn(() => null), t = vi.fn(), e = "Custom error message", l = vi.fn();
19
- c(a, t, { maxAttempts: 3, errorMessage: e, onError: l });
20
- for (let n = 0; n < 3; n++)
21
- vi.advanceTimersByTime(100);
22
- expect(l).toHaveBeenCalledTimes(1), expect(l).toHaveBeenCalledWith(new Error(e));
23
- }), it("should use default values when options are not provided", () => {
24
- const a = vi.fn(() => null), t = vi.fn(), e = vi.fn();
25
- c(a, t, { onError: e });
26
- for (let l = 0; l < 20; l++)
27
- vi.advanceTimersByTime(100);
28
- expect(a).toHaveBeenCalledTimes(21), expect(t).not.toHaveBeenCalled(), expect(e).toHaveBeenCalledTimes(1), expect(e).toHaveBeenCalledWith(new Error("[maz-ui](checkAvailability) Nothing found after 20 attempts"));
29
- }), it("should stop retrying if expectedValue is not met", () => {
30
- const a = vi.fn(() => "unexpectedValue"), t = vi.fn();
31
- c(a, t, { maxAttempts: 5, interval: 50, expectedValue: "expectedValue" });
32
- for (let e = 0; e < 5; e++)
33
- vi.advanceTimersByTime(50);
34
- expect(a).toHaveBeenCalledTimes(6), expect(t).not.toHaveBeenCalled();
35
- }), it("should call callback if expectedValue is met", () => {
36
- const a = vi.fn(() => "expectedValue"), t = vi.fn();
37
- c(a, t, { expectedValue: "expectedValue" }), expect(a).toHaveBeenCalledTimes(1), expect(t).toHaveBeenCalledTimes(1), expect(t).toHaveBeenCalledWith("expectedValue");
38
- }), it("should continue retrying until expectedValue is met", () => {
39
- let a = 0;
40
- const t = vi.fn(() => (a++, a === 3 ? "expectedValue" : "unexpectedValue")), e = vi.fn();
41
- c(t, e, { maxAttempts: 5, interval: 50, expectedValue: "expectedValue" });
42
- for (let l = 0; l < 3; l++)
43
- vi.advanceTimersByTime(50);
44
- expect(t).toHaveBeenCalledTimes(3), expect(e).toHaveBeenCalledTimes(1), expect(e).toHaveBeenCalledWith("expectedValue");
45
- });
46
- });
@@ -1,16 +0,0 @@
1
- import { countryCodeToUnicodeFlag as r } from "../countryCodeToUnicodeFlag.js";
2
- describe("countryCodeToUnicodeFlag", () => {
3
- it('devrait retourner un drapeau Unicode pour la locale "fr"', () => {
4
- const e = r("fr");
5
- expect(e).toBe("🇫🇷");
6
- }), it('devrait retourner un drapeau Unicode pour la locale "de"', () => {
7
- const e = r("de");
8
- expect(e).toBe("🇩🇪");
9
- }), it('devrait retourner un drapeau Unicode pour la locale "es"', () => {
10
- const e = r("es");
11
- expect(e).toBe("🇪🇸");
12
- }), it('devrait retourner un drapeau Unicode pour la locale "it"', () => {
13
- const e = r("it");
14
- expect(e).toBe("🇮🇹");
15
- });
16
- });
@@ -1,16 +0,0 @@
1
- import { debounceId as t } from "../debounceId.js";
2
- describe("given debounceId function", () => {
3
- describe("when calling a debounced function multiple times", () => {
4
- it("then it should only execute once after the delay", async () => {
5
- vi.useFakeTimers();
6
- const e = vi.fn().mockResolvedValue("result"), n = t("test", e, 100);
7
- n(1, 2, 3), n(4, 5, 6), n(7, 8, 9), expect(e).not.toHaveBeenCalled(), await vi.runAllTimersAsync(), expect(e).toHaveBeenCalledTimes(1), expect(e).toHaveBeenCalledWith(7, 8, 9), vi.useRealTimers();
8
- });
9
- }), describe("when calling debounced functions with different identifiers", () => {
10
- it("then it should execute separately for each identifier", async () => {
11
- vi.useFakeTimers();
12
- const e = vi.fn().mockResolvedValue("result"), n = t("id1", e, 100), i = t("id2", e, 100);
13
- n(1, 2, 3), i(4, 5, 6), await vi.runAllTimersAsync(), expect(e).toHaveBeenCalledTimes(2), expect(e).toHaveBeenNthCalledWith(1, 1, 2, 3), expect(e).toHaveBeenNthCalledWith(2, 4, 5, 6), vi.useRealTimers();
14
- });
15
- });
16
- });
@@ -1,12 +0,0 @@
1
- import { debounceCallback as a } from "../debounceCallback.js";
2
- describe("debounceCallback.ts", () => {
3
- it("delaying Callback Execution", () => {
4
- vi.useFakeTimers();
5
- const e = vi.fn();
6
- a(e, 1e3), expect(e).not.toHaveBeenCalled(), vi.advanceTimersByTime(1e3), expect(e).toHaveBeenCalledTimes(1);
7
- }), it("cancel Previous Callbacks", () => {
8
- vi.useFakeTimers();
9
- const e = vi.fn();
10
- a(e, 1e3), vi.advanceTimersByTime(750), a(e, 1e3), vi.advanceTimersByTime(750), expect(e).not.toHaveBeenCalled();
11
- });
12
- });
@@ -1,46 +0,0 @@
1
- import { isEqual as e } from "../isEqual.js";
2
- describe("given isEqual function", () => {
3
- describe("when comparing primitive values", () => {
4
- it("then it should return true for equal values", () => {
5
- expect(e(5, 5)).toBe(!0), expect(e("test", "test")).toBe(!0), expect(e(!0, !0)).toBe(!0), expect(e(null, null)).toBe(!0), expect(e(void 0, void 0)).toBe(!0);
6
- }), it("then it should return false for different values", () => {
7
- expect(e(5, 6)).toBe(!1), expect(e("test", "test2")).toBe(!1), expect(e(!0, !1)).toBe(!1), expect(e(null, void 0)).toBe(!1);
8
- });
9
- }), describe("when comparing arrays", () => {
10
- it("then it should return true for equal arrays", () => {
11
- expect(e([1, 2, 3], [1, 2, 3])).toBe(!0), expect(e([1, [2, 3]], [1, [2, 3]])).toBe(!0);
12
- }), it("then it should return false for different arrays", () => {
13
- expect(e([1, 2, 3], [1, 2, 4])).toBe(!1), expect(e([1, 2, 3], [1, 2])).toBe(!1), expect(e([1, [2, 3]], [1, [2, 4]])).toBe(!1);
14
- });
15
- }), describe("when comparing objects", () => {
16
- it("then it should return true for equal objects", () => {
17
- expect(e({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(!0), expect(e({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } })).toBe(!0);
18
- }), it("then it should return false for different objects", () => {
19
- expect(e({ a: 1, b: 2 }, { a: 1, b: 3 })).toBe(!1), expect(e({ a: 1, b: 2 }, { a: 1, c: 2 })).toBe(!1), expect(e({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } })).toBe(!1);
20
- });
21
- }), describe("when comparing Date types", () => {
22
- it("then it should return true for equal dates", () => {
23
- const t = /* @__PURE__ */ new Date();
24
- expect(e(t, t)).toBe(!0), expect(e(/* @__PURE__ */ new Date("2021-01-02"), /* @__PURE__ */ new Date("2021-01-02"))).toBe(!0);
25
- }), it("then it should return false", () => {
26
- expect(e(/* @__PURE__ */ new Date("2021-01-01"), /* @__PURE__ */ new Date("2021-01-02"))).toBe(!1);
27
- });
28
- }), describe("when comparing Symbol types", () => {
29
- it("then it should return true for equal symbol", () => {
30
- const t = Symbol("test");
31
- expect(e(t, t)).toBe(!0);
32
- }), it("then it should return false", () => {
33
- expect(e(Symbol("test"), Symbol("test"))).toBe(!1);
34
- });
35
- }), describe("when comparing bigint types", () => {
36
- it("then it should return true for equal bigint", () => {
37
- expect(e(BigInt(123), BigInt(123))).toBe(!0);
38
- }), it("then it should return false", () => {
39
- expect(e(BigInt(123), BigInt(124))).toBe(!1);
40
- });
41
- }), describe("when comparing mixed types", () => {
42
- it("then it should return false", () => {
43
- expect(e(5, "5")).toBe(!1), expect(e([], {})).toBe(!1), expect(e({ a: 1 }, [1])).toBe(!1);
44
- });
45
- });
46
- });