@molopos/shared 2.0.90 → 2.1.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.
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0
|
|
1
|
+
{"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.1.0","description":"Shared between backend and frontend repos","license":"ISC","repository":{"type":"git","url":"https://github.com/unicubate/molopos-shared.git"},"dependencies":{"class-transformer":"^0.5.1","date-fns":"^4.4.0","luxon":"^3.7.2"}}
|
package/date/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/date/index.test.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("./index");
|
|
4
|
-
const enum_1 = require("../enum");
|
|
5
|
-
describe("Date", () => {
|
|
6
|
-
it("formateDDDateISO", () => {
|
|
7
|
-
const dateNow = (0, index_1.formateDateUnixInteger)(new Date());
|
|
8
|
-
expect(dateNow).not.toBeNull();
|
|
9
|
-
expect(dateNow).toBeDefined();
|
|
10
|
-
});
|
|
11
|
-
it("dateTimeNowUtc", () => {
|
|
12
|
-
const dateNow = (0, index_1.dateTimeNowUtc)();
|
|
13
|
-
expect(dateNow).not.toBeNull();
|
|
14
|
-
expect(dateNow).toBeDefined();
|
|
15
|
-
});
|
|
16
|
-
it("dateTimeNowUtcUnixInteger", () => {
|
|
17
|
-
const dateNow = (0, index_1.dateTimeNowUtcUnixInteger)();
|
|
18
|
-
expect(dateNow).not.toBeNull();
|
|
19
|
-
expect(dateNow).toBeDefined();
|
|
20
|
-
});
|
|
21
|
-
it("formateDateUnixInteger", () => {
|
|
22
|
-
const dateNow = (0, index_1.formateDateUnixInteger)(new Date());
|
|
23
|
-
expect(dateNow).not.toBeNull();
|
|
24
|
-
expect(dateNow).toBeDefined();
|
|
25
|
-
});
|
|
26
|
-
it("recurrenceDate isRecurrence = true", () => {
|
|
27
|
-
jest.useFakeTimers();
|
|
28
|
-
jest.setSystemTime(new Date(2026, 9, 1, 14, 0, 0));
|
|
29
|
-
const date = new Date(2025, 6, 10, 2, 0, 0);
|
|
30
|
-
const nextDate = (recurrence) => (0, index_1.recurrenceDate)({
|
|
31
|
-
date,
|
|
32
|
-
isRecurrence: true,
|
|
33
|
-
recurrence,
|
|
34
|
-
});
|
|
35
|
-
expect(nextDate(enum_1.RecurrenceEnum.Daily)).toEqual(new Date(2026, 9, 2, 14, 0, 0));
|
|
36
|
-
expect(nextDate(enum_1.RecurrenceEnum.Weekly)).toEqual(new Date(2026, 9, 8, 14, 0, 0));
|
|
37
|
-
expect(nextDate(enum_1.RecurrenceEnum.Monthly)).toEqual(new Date(2026, 9, 10, 14, 0, 0));
|
|
38
|
-
expect(nextDate(enum_1.RecurrenceEnum.Yearly)).toEqual(new Date(2027, 6, 10, 14, 0, 0));
|
|
39
|
-
jest.useRealTimers();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/utils/index.test.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("./index");
|
|
4
|
-
describe("Utils", () => {
|
|
5
|
-
test("fromCents", () => {
|
|
6
|
-
const result = (0, index_1.fromCents)(100);
|
|
7
|
-
expect(result).toEqual(1);
|
|
8
|
-
expect(result).not.toBeNull();
|
|
9
|
-
});
|
|
10
|
-
test("toCents", () => {
|
|
11
|
-
const result = (0, index_1.toCents)(1);
|
|
12
|
-
expect(result).toEqual(100);
|
|
13
|
-
expect(result).not.toBeNull();
|
|
14
|
-
});
|
|
15
|
-
test("calculVat", () => {
|
|
16
|
-
const result = (0, index_1.calculVat)({ value: 100, percentage: 20 });
|
|
17
|
-
expect(result).toEqual(20);
|
|
18
|
-
expect(result).not.toBeNull();
|
|
19
|
-
});
|
|
20
|
-
test("calculDiscount", () => {
|
|
21
|
-
const result = (0, index_1.calculDiscount)({ value: 100, percentage: 20 });
|
|
22
|
-
expect(result).toEqual(20);
|
|
23
|
-
expect(result).not.toBeNull();
|
|
24
|
-
});
|
|
25
|
-
test("formatePrice", () => {
|
|
26
|
-
const result = (0, index_1.formatePrice)({
|
|
27
|
-
value: 205.35714285714286,
|
|
28
|
-
currency: "EUR",
|
|
29
|
-
locale: "fr",
|
|
30
|
-
});
|
|
31
|
-
expect(result.toString()).not.toBeNull();
|
|
32
|
-
});
|
|
33
|
-
test("formatPercent", () => {
|
|
34
|
-
const result = (0, index_1.formatPercent)({ value: 20, locale: "fr" });
|
|
35
|
-
expect(result).not.toBeNull();
|
|
36
|
-
});
|
|
37
|
-
test("capitalizeFirstLetter", () => {
|
|
38
|
-
const result = (0, index_1.capitalizeFirstLetter)("john doe");
|
|
39
|
-
expect(result).not.toBeNull();
|
|
40
|
-
expect(result).toBeDefined();
|
|
41
|
-
expect(result).toEqual("John Doe");
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("./index");
|
|
4
|
-
describe("URLEndpoint", () => {
|
|
5
|
-
test("URLEndpoint", () => {
|
|
6
|
-
const baseUrl = "https://api.example.com";
|
|
7
|
-
const result = (0, index_1.URLEndpoint)({
|
|
8
|
-
baseUrl,
|
|
9
|
-
endpoint: "/users/:id",
|
|
10
|
-
params: { id: "123" },
|
|
11
|
-
query: { limit: 10, page: 1 },
|
|
12
|
-
});
|
|
13
|
-
expect(result).toEqual(`${baseUrl}/users/123?limit=10&page=1`);
|
|
14
|
-
});
|
|
15
|
-
});
|