@blackcode_sa/metaestetics-api 1.11.1 → 1.11.2

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 (36) hide show
  1. package/dist/admin/index.d.mts +324 -330
  2. package/dist/admin/index.d.ts +324 -330
  3. package/dist/backoffice/index.d.mts +67 -283
  4. package/dist/backoffice/index.d.ts +67 -283
  5. package/dist/backoffice/index.js +6 -114
  6. package/dist/backoffice/index.mjs +6 -112
  7. package/dist/index.d.mts +3037 -3100
  8. package/dist/index.d.ts +3037 -3100
  9. package/dist/index.js +129 -379
  10. package/dist/index.mjs +130 -379
  11. package/package.json +1 -1
  12. package/src/backoffice/expo-safe/index.ts +0 -2
  13. package/src/backoffice/services/__tests__/brand.service.test.ts +196 -0
  14. package/src/backoffice/services/__tests__/category.service.test.ts +201 -0
  15. package/src/backoffice/services/__tests__/product.service.test.ts +358 -0
  16. package/src/backoffice/services/__tests__/requirement.service.test.ts +226 -0
  17. package/src/backoffice/services/__tests__/subcategory.service.test.ts +181 -0
  18. package/src/backoffice/services/__tests__/technology.service.test.ts +1097 -0
  19. package/src/backoffice/services/technology.service.ts +10 -122
  20. package/src/backoffice/types/index.ts +0 -1
  21. package/src/backoffice/types/product.types.ts +1 -3
  22. package/src/backoffice/types/technology.types.ts +4 -4
  23. package/src/backoffice/validations/schemas.ts +9 -35
  24. package/src/services/appointment/appointment.service.ts +5 -0
  25. package/src/services/appointment/utils/appointment.utils.ts +113 -124
  26. package/src/services/procedure/procedure.service.ts +234 -434
  27. package/src/types/appointment/index.ts +37 -43
  28. package/src/types/clinic/index.ts +6 -1
  29. package/src/types/patient/medical-info.types.ts +3 -3
  30. package/src/types/procedure/index.ts +17 -20
  31. package/src/validations/appointment.schema.ts +118 -170
  32. package/src/validations/clinic.schema.ts +6 -1
  33. package/src/validations/patient/medical-info.schema.ts +2 -7
  34. package/src/backoffice/services/README.md +0 -40
  35. package/src/backoffice/services/constants.service.ts +0 -268
  36. package/src/backoffice/types/admin-constants.types.ts +0 -69
@@ -0,0 +1,181 @@
1
+ import { SubcategoryService } from "../subcategory.service";
2
+ import { Subcategory } from "../../types/subcategory.types";
3
+ import {
4
+ collection,
5
+ doc,
6
+ getDoc,
7
+ getDocs,
8
+ addDoc,
9
+ updateDoc,
10
+ query,
11
+ where,
12
+ } from "firebase/firestore";
13
+
14
+ jest.mock("firebase/firestore");
15
+ jest.mock("../../../config/firebase", () => ({
16
+ getFirebaseInstance: jest.fn().mockResolvedValue({
17
+ db: {},
18
+ auth: {},
19
+ }),
20
+ }));
21
+
22
+ const COLLECTION = "backoffice_categories";
23
+ const SUB_COLLECTION = "subcategories";
24
+ const mockDb = {} as any;
25
+ const CATEGORY_ID = "test-category-id";
26
+
27
+ describe("SubcategoryService", () => {
28
+ let service: SubcategoryService;
29
+
30
+ const mockSubcategory: Omit<Subcategory, "id" | "createdAt" | "updatedAt"> = {
31
+ name: "Test Subcategory",
32
+ description: "Test Description",
33
+ categoryId: CATEGORY_ID,
34
+ isActive: true,
35
+ };
36
+
37
+ beforeEach(() => {
38
+ jest.clearAllMocks();
39
+ service = new SubcategoryService();
40
+ });
41
+
42
+ describe("create", () => {
43
+ it("treba da kreira novu podkategoriju", async () => {
44
+ const mockDocRef = { id: "test-id" };
45
+ (collection as jest.Mock).mockReturnValue("subcategories-collection");
46
+ (addDoc as jest.Mock).mockResolvedValue(mockDocRef);
47
+
48
+ const result = await service.create(CATEGORY_ID, mockSubcategory);
49
+
50
+ expect(collection).toHaveBeenCalledWith(
51
+ mockDb,
52
+ COLLECTION,
53
+ CATEGORY_ID,
54
+ SUB_COLLECTION
55
+ );
56
+ expect(addDoc).toHaveBeenCalledWith(
57
+ "subcategories-collection",
58
+ expect.objectContaining({
59
+ ...mockSubcategory,
60
+ categoryId: CATEGORY_ID,
61
+ createdAt: expect.any(Date),
62
+ updatedAt: expect.any(Date),
63
+ })
64
+ );
65
+ });
66
+ });
67
+
68
+ describe("getAllByCategoryId", () => {
69
+ it("treba da vrati sve aktivne podkategorije za kategoriju", async () => {
70
+ const mockDocs = [
71
+ {
72
+ id: "sub-1",
73
+ data: () => ({
74
+ ...mockSubcategory,
75
+ createdAt: new Date(),
76
+ updatedAt: new Date(),
77
+ }),
78
+ },
79
+ ];
80
+
81
+ (collection as jest.Mock).mockReturnValue("subcategories-collection");
82
+ (query as jest.Mock).mockReturnValue("filtered-query");
83
+ (where as jest.Mock).mockReturnValue("where-clause");
84
+ (getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
85
+
86
+ const results = await service.getAllByCategoryId(CATEGORY_ID);
87
+
88
+ expect(collection).toHaveBeenCalledWith(
89
+ mockDb,
90
+ COLLECTION,
91
+ CATEGORY_ID,
92
+ SUB_COLLECTION
93
+ );
94
+ });
95
+ });
96
+
97
+ describe("update", () => {
98
+ it("treba da ažurira postojeću podkategoriju", async () => {
99
+ const updateData = { name: "Updated Subcategory" };
100
+ const SUBCATEGORY_ID = "test-sub-id";
101
+
102
+ (collection as jest.Mock).mockReturnValue("subcategories-collection");
103
+ (doc as jest.Mock).mockReturnValue("doc-ref");
104
+ (updateDoc as jest.Mock).mockResolvedValue(undefined);
105
+ (getDoc as jest.Mock).mockResolvedValue({
106
+ exists: () => true,
107
+ id: SUBCATEGORY_ID,
108
+ data: () => ({
109
+ ...mockSubcategory,
110
+ ...updateData,
111
+ createdAt: new Date(),
112
+ updatedAt: new Date(),
113
+ }),
114
+ });
115
+
116
+ await service.update(CATEGORY_ID, SUBCATEGORY_ID, updateData);
117
+
118
+ expect(collection).toHaveBeenCalledWith(
119
+ mockDb,
120
+ COLLECTION,
121
+ CATEGORY_ID,
122
+ SUB_COLLECTION
123
+ );
124
+ });
125
+ });
126
+
127
+ describe("delete", () => {
128
+ it("treba da izvrši soft delete podkategorije", async () => {
129
+ const SUBCATEGORY_ID = "test-sub-id";
130
+
131
+ (collection as jest.Mock).mockReturnValue("subcategories-collection");
132
+ (doc as jest.Mock).mockReturnValue("doc-ref");
133
+ (updateDoc as jest.Mock).mockResolvedValue(undefined);
134
+ (getDoc as jest.Mock).mockResolvedValue({
135
+ exists: () => true,
136
+ id: SUBCATEGORY_ID,
137
+ data: () => ({
138
+ ...mockSubcategory,
139
+ createdAt: new Date(),
140
+ updatedAt: new Date(),
141
+ }),
142
+ });
143
+
144
+ await service.delete(CATEGORY_ID, SUBCATEGORY_ID);
145
+
146
+ expect(collection).toHaveBeenCalledWith(
147
+ mockDb,
148
+ COLLECTION,
149
+ CATEGORY_ID,
150
+ SUB_COLLECTION
151
+ );
152
+ });
153
+ });
154
+
155
+ describe("getById", () => {
156
+ it("treba da vrati podkategoriju po ID-u", async () => {
157
+ const SUBCATEGORY_ID = "test-sub-id";
158
+
159
+ (collection as jest.Mock).mockReturnValue("subcategories-collection");
160
+ (doc as jest.Mock).mockReturnValue("doc-ref");
161
+ (getDoc as jest.Mock).mockResolvedValue({
162
+ exists: () => true,
163
+ id: SUBCATEGORY_ID,
164
+ data: () => ({
165
+ ...mockSubcategory,
166
+ createdAt: new Date(),
167
+ updatedAt: new Date(),
168
+ }),
169
+ });
170
+
171
+ const result = await service.getById(CATEGORY_ID, SUBCATEGORY_ID);
172
+
173
+ expect(collection).toHaveBeenCalledWith(
174
+ mockDb,
175
+ COLLECTION,
176
+ CATEGORY_ID,
177
+ SUB_COLLECTION
178
+ );
179
+ });
180
+ });
181
+ });