cat-documents-ng 0.1.28 → 0.1.30

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 (92) hide show
  1. package/ng-package.json +11 -0
  2. package/package.json +20 -25
  3. package/{Shared/constant/ERROR.d.ts → src/Shared/constant/ERROR.ts} +38 -36
  4. package/src/Shared/constant/PERMISSIONS.ts +16 -0
  5. package/src/Shared/constant/SHARED.ts +312 -0
  6. package/{Shared/constant/URLS.d.ts → src/Shared/constant/URLS.ts} +65 -60
  7. package/src/Shared/services/app-config.service.spec.ts +19 -0
  8. package/src/Shared/services/app-config.service.ts +73 -0
  9. package/{Shared/services/global-error.handler.d.ts → src/Shared/services/global-error.handler.ts} +29 -27
  10. package/src/Shared/services/session.service.spec.ts +16 -0
  11. package/src/Shared/services/session.service.ts +76 -0
  12. package/src/assets/config/api.config.json +20 -0
  13. package/src/lib/document/components/document-container/document-container.component.html +14 -0
  14. package/src/lib/document/components/document-container/document-container.component.scss +8 -0
  15. package/src/lib/document/components/document-container/document-container.component.spec.ts +110 -0
  16. package/src/lib/document/components/document-container/document-container.component.ts +173 -0
  17. package/src/lib/document/components/document-list/document-list.component.html +81 -0
  18. package/src/lib/document/components/document-list/document-list.component.scss +82 -0
  19. package/src/lib/document/components/document-list/document-list.component.spec.ts +96 -0
  20. package/src/lib/document/components/document-list/document-list.component.ts +244 -0
  21. package/src/lib/document/components/document-list-item/document-list-item.component.html +36 -0
  22. package/src/lib/document/components/document-list-item/document-list-item.component.scss +34 -0
  23. package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +75 -0
  24. package/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
  25. package/src/lib/document/components/document-upload/document-upload.component.html +56 -0
  26. package/src/lib/document/components/document-upload/document-upload.component.scss +32 -0
  27. package/src/lib/document/components/document-upload/document-upload.component.spec.ts +95 -0
  28. package/src/lib/document/components/document-upload/document-upload.component.ts +162 -0
  29. package/src/lib/document/components/document-viewer/document-viewer.component.html +98 -0
  30. package/src/lib/document/components/document-viewer/document-viewer.component.scss +54 -0
  31. package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +79 -0
  32. package/src/lib/document/components/document-viewer/document-viewer.component.ts +106 -0
  33. package/src/lib/document/components/folder-block/folder-block.component.html +46 -0
  34. package/src/lib/document/components/folder-block/folder-block.component.scss +9 -0
  35. package/src/lib/document/components/folder-block/folder-block.component.spec.ts +70 -0
  36. package/{lib/document/components/folder-block/folder-block.component.d.ts → src/lib/document/components/folder-block/folder-block.component.ts} +53 -37
  37. package/src/lib/document/components/folder-container/folder-container.component.html +2 -0
  38. package/src/lib/document/components/folder-container/folder-container.component.scss +0 -0
  39. package/src/lib/document/components/folder-container/folder-container.component.spec.ts +27 -0
  40. package/src/lib/document/components/folder-container/folder-container.component.ts +37 -0
  41. package/src/lib/document/components/linked-document/linked-document.component.html +23 -0
  42. package/src/lib/document/components/linked-document/linked-document.component.scss +10 -0
  43. package/src/lib/document/components/linked-document/linked-document.component.spec.ts +61 -0
  44. package/src/lib/document/components/linked-document/linked-document.component.ts +49 -0
  45. package/src/lib/document/directives/document.directive.ts +32 -0
  46. package/src/lib/document/directives/permission.directive.spec.ts +0 -0
  47. package/src/lib/document/directives/permission.directive.ts +66 -0
  48. package/src/lib/document/document.module.ts +241 -0
  49. package/{lib/document/models/document-alert.model.d.ts → src/lib/document/models/document-alert.model.ts} +45 -38
  50. package/src/lib/document/models/document-type.model.ts +44 -0
  51. package/src/lib/document/models/document.model.ts +53 -0
  52. package/{lib/document/models/folder.model.d.ts → src/lib/document/models/folder.model.ts} +35 -29
  53. package/src/lib/document/services/document-http.service.spec.ts +119 -0
  54. package/src/lib/document/services/document-http.service.ts +125 -0
  55. package/src/lib/document/services/document-upload.service.spec.ts +99 -0
  56. package/src/lib/document/services/document-upload.service.ts +127 -0
  57. package/src/lib/document/services/document.service.ts +29 -0
  58. package/src/lib/document/services/file-format.service.spec.ts +16 -0
  59. package/src/lib/document/services/file-format.service.ts +41 -0
  60. package/src/lib/document/state/document.query.ts +52 -0
  61. package/{lib/document/state/document.service.d.ts → src/lib/document/state/document.service.ts} +95 -64
  62. package/{lib/document/state/document.state.d.ts → src/lib/document/state/document.state.ts} +52 -36
  63. package/src/lib/document/state/document.store.ts +51 -0
  64. package/{public-api.d.ts → src/public-api.ts} +10 -6
  65. package/tsconfig.lib.json +15 -0
  66. package/tsconfig.lib.prod.json +11 -0
  67. package/tsconfig.spec.json +15 -0
  68. package/Shared/constant/PERMISSIONS.d.ts +0 -15
  69. package/Shared/constant/SHARED.d.ts +0 -209
  70. package/Shared/services/app-config.service.d.ts +0 -51
  71. package/Shared/services/session.service.d.ts +0 -46
  72. package/fesm2022/cat-documents-ng.mjs +0 -2538
  73. package/fesm2022/cat-documents-ng.mjs.map +0 -1
  74. package/index.d.ts +0 -5
  75. package/lib/document/components/document-container/document-container.component.d.ts +0 -85
  76. package/lib/document/components/document-list/document-list.component.d.ts +0 -160
  77. package/lib/document/components/document-list-item/document-list-item.component.d.ts +0 -28
  78. package/lib/document/components/document-upload/document-upload.component.d.ts +0 -120
  79. package/lib/document/components/document-viewer/document-viewer.component.d.ts +0 -73
  80. package/lib/document/components/folder-container/folder-container.component.d.ts +0 -29
  81. package/lib/document/components/linked-document/linked-document.component.d.ts +0 -38
  82. package/lib/document/directives/document.directive.d.ts +0 -20
  83. package/lib/document/directives/permission.directive.d.ts +0 -38
  84. package/lib/document/document.module.d.ts +0 -40
  85. package/lib/document/models/document-type.model.d.ts +0 -37
  86. package/lib/document/models/document.model.d.ts +0 -44
  87. package/lib/document/services/document-http.service.d.ts +0 -69
  88. package/lib/document/services/document-upload.service.d.ts +0 -67
  89. package/lib/document/services/document.service.d.ts +0 -20
  90. package/lib/document/services/file-format.service.d.ts +0 -23
  91. package/lib/document/state/document.query.d.ts +0 -42
  92. package/lib/document/state/document.store.d.ts +0 -29
@@ -0,0 +1,241 @@
1
+ import { APP_INITIALIZER, NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { DocumentContainerComponent } from './components/document-container/document-container.component';
4
+ import { FolderContainerComponent } from './components/folder-container/folder-container.component';
5
+ import { FolderBlockComponent } from './components/folder-block/folder-block.component';
6
+ import { DocumentListComponent } from './components/document-list/document-list.component';
7
+ import { AccordionModule } from 'primeng/accordion';
8
+ import { DocumentListItemComponent } from './components/document-list-item/document-list-item.component';
9
+ import { ButtonModule } from 'primeng/button';
10
+ import { SidebarModule } from 'primeng/sidebar';
11
+ import { FileUploadModule } from 'primeng/fileupload';
12
+ import { DocumentUploadComponent } from './components/document-upload/document-upload.component';
13
+ import { MessageService } from 'primeng/api';
14
+ import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
15
+ import { ProgressBarModule } from 'primeng/progressbar';
16
+ import { BadgeModule } from 'primeng/badge';
17
+ import { ListboxModule } from 'primeng/listbox';
18
+ import { TimelineModule } from 'primeng/timeline';
19
+ import { CheckboxModule } from 'primeng/checkbox';
20
+ import { InputTextareaModule } from 'primeng/inputtextarea';
21
+ import { FormsModule } from '@angular/forms';
22
+ import { DocumentViewerComponent } from './components/document-viewer/document-viewer.component';
23
+ import { PdfViewerModule } from 'ng2-pdf-viewer';
24
+ import { DialogModule } from 'primeng/dialog';
25
+ import { AppConfigService } from '../../Shared/services/app-config.service';
26
+ import { GlobalErrorHandler } from '../../Shared/services/global-error.handler';
27
+ import { DropdownModule } from 'primeng/dropdown';
28
+ import { InputTextModule } from 'primeng/inputtext';
29
+ import { DocumentDirective } from './directives/document.directive';
30
+ import { HasPermissionDirective } from './directives/permission.directive';
31
+ import { LinkedDocumentComponent } from './components/linked-document/linked-document.component';
32
+
33
+ /**
34
+ * @module DocumentModule
35
+ *
36
+ * The `DocumentModule` handles the organization and display of document and folder components
37
+ * in the application. This module is designed to support features like folder containers,
38
+ * document lists, and individual document items.
39
+ */
40
+ @NgModule({
41
+ declarations: [
42
+ /**
43
+ * The main container for managing documents.
44
+ * DocumentContainerComponent
45
+ */
46
+ DocumentContainerComponent,
47
+
48
+ /**
49
+ * A container component to manage folders.
50
+ * FolderContainerComponent
51
+ */
52
+ FolderContainerComponent,
53
+
54
+ /**
55
+ * A block component that represents an individual folder.
56
+ * FolderBlockComponent
57
+ */
58
+ FolderBlockComponent,
59
+
60
+ /**
61
+ * A component to display a list of documents.
62
+ * DocumentListComponent
63
+ */
64
+ DocumentListComponent,
65
+
66
+ /**
67
+ * A component representing an individual item in the document list.
68
+ * DocumentListItemComponent
69
+ */
70
+ DocumentListItemComponent,
71
+
72
+ /**
73
+ * A component representing to upload a file.
74
+ */
75
+ DocumentUploadComponent,
76
+
77
+ /**
78
+ * A component representing and allow you to view the document.
79
+ */
80
+ DocumentViewerComponent,
81
+
82
+ /**
83
+ * A directive to show the document.
84
+ */
85
+ DocumentDirective,
86
+
87
+ /**
88
+ * A directive to give permission.
89
+ */
90
+ HasPermissionDirective,
91
+
92
+ /**
93
+ * A component which have linked documents.
94
+ */
95
+ LinkedDocumentComponent,
96
+
97
+ ],
98
+ imports: [
99
+ /**
100
+ * Angular's CommonModule is imported to access common directives like `ngIf` and `ngFor`.
101
+ */
102
+ CommonModule,
103
+
104
+ /**
105
+ * PrimeNG AccordionModule is used for creating collapsible sections in the UI.
106
+ */
107
+ AccordionModule,
108
+
109
+ /**
110
+ * HttpClienModule for the http calls
111
+ */
112
+ HttpClientModule,
113
+
114
+ /**
115
+ * PrimeNG ButtonModule is used for creating buttons in the UI.
116
+ */
117
+ ButtonModule,
118
+
119
+ /**
120
+ * PrimeNG SidebarModule is used for creating sidebar in the UI.
121
+ */
122
+ SidebarModule,
123
+
124
+ /**
125
+ * PrimeNG FileUploadModule is used for uploading file.
126
+ */
127
+ FileUploadModule,
128
+
129
+ /**
130
+ * PrimeNG ProgressBarModule is used for showing progress.
131
+ */
132
+ ProgressBarModule,
133
+
134
+ /**
135
+ * PrimeNG BadgeModule is used for showing badge value.
136
+ */
137
+ BadgeModule,
138
+
139
+ /**
140
+ * PrimeNG ListboxModule is used for showing listbox value.
141
+ */
142
+ ListboxModule,
143
+
144
+ /**
145
+ * PrimeNG CheckboxModule is used for showing checkbox value.
146
+ */
147
+ CheckboxModule,
148
+
149
+ /**
150
+ * PrimeNG TimelineModule is used for showing timeline value.
151
+ */
152
+ TimelineModule,
153
+ /**
154
+ * PrimeNG InputTextareaModule is used for showing textarea value.
155
+ */
156
+ InputTextareaModule,
157
+ /**
158
+ * FormsModule to handle the forms.
159
+ */
160
+ FormsModule,
161
+ /**
162
+ * PdfViewerModule to handle and make visible the pdf.
163
+ */
164
+ PdfViewerModule,
165
+ /**
166
+ * PrimeNG DialogModule is used for showing dialog.
167
+ */
168
+ DialogModule,
169
+ /**
170
+ * PrimeNG DropdownModule is used for creating dropdown menus, allowing users to select options from a list.
171
+ */
172
+ DropdownModule,
173
+ /**
174
+ * PrimeNG InputTextModule is used for creating InputTextFeilds, allowing users to enter name for a document.
175
+ */
176
+ InputTextModule
177
+
178
+
179
+ ],
180
+ exports: [
181
+ /**
182
+ * A directive to give permission.
183
+ */
184
+ HasPermissionDirective,
185
+ /**
186
+ * Exports the `DocumentContainerComponent` to be used in other modules.
187
+ */
188
+ DocumentContainerComponent,
189
+ /**
190
+ * Exports the `DocumentViewerComponent` to be used in other modules.
191
+ */
192
+ DocumentViewerComponent,
193
+ /**
194
+ * A component to display a list of documents.
195
+ * DocumentListComponent
196
+ */
197
+ DocumentListComponent,
198
+ /**
199
+ * A directive to show the document.
200
+ */
201
+ DocumentDirective,
202
+
203
+
204
+ ],
205
+ providers: [
206
+ /**
207
+ * Provide the messageservice to be used in other components.
208
+ */
209
+ MessageService,
210
+
211
+ /**
212
+ * Provide the messageservice to be used in other components.
213
+ */
214
+ { provide: GlobalErrorHandler, useClass: GlobalErrorHandler },
215
+ /**
216
+ * Initializes the application configuration by loading it from the AppConfigService
217
+ * before the application starts.
218
+ * This ensures that the configuration is available for the rest of the app when needed.
219
+ * The configuration is loaded asynchronously using the APP_INITIALIZER.
220
+ * @returns {Function} - A function that loads the configuration from the AppConfigService.
221
+ */
222
+ {
223
+ provide: APP_INITIALIZER,
224
+ /**
225
+ * This useFactory is executed when the app initializes.
226
+ * It calls the AppConfigService to load the configuration.
227
+ * If an error occurs, it throws an error.
228
+ * @param {AppConfigService} configService - The service responsible for loading the application configuration.
229
+ * @returns {Function} - A function that loads the configuration from the AppConfigService.
230
+ */
231
+ useFactory: (configService: AppConfigService) => () =>
232
+ configService.loadAppConfig().catch((error) => {
233
+ throw new Error(error);
234
+ }),
235
+ deps: [AppConfigService],
236
+ multi: true,
237
+ },
238
+
239
+ ]
240
+ })
241
+ export class DocumentModule { }
@@ -1,38 +1,45 @@
1
- /**
2
- * The `DocumentAlertModel` is responsible for managing and displaying alert messages for documents.
3
- * @export
4
- * @class DocumentAlertModel
5
- * @typedef {DocumentAlertModel} - Represents the document alert model.
6
- */
7
- export declare class DocumentAlertModel {
8
- /**
9
- * The unique identifier for the document alert.
10
- * @type {string}
11
- */
12
- _id: string;
13
- /**
14
- * The alert status for the document.
15
- * @type {string}
16
- */
17
- alertStatus?: string;
18
- /**
19
- * The context ID for the document.
20
- * @type {?string}
21
- */
22
- contextId?: string;
23
- /**
24
- * The document ID for the document.
25
- * @type {?string}
26
- */
27
- documentId?: string;
28
- /**
29
- * The alert message for the document.
30
- * @type {?string}
31
- */
32
- alertMessage?: string;
33
- /**
34
- * The alert type for the document.
35
- * @type {?string}
36
- */
37
- status?: string;
38
- }
1
+ import { SHARED } from "../../../Shared/constant/SHARED";
2
+
3
+ /**
4
+ * The `DocumentAlertModel` is responsible for managing and displaying alert messages for documents.
5
+ * @export
6
+ * @class DocumentAlertModel
7
+ * @typedef {DocumentAlertModel} - Represents the document alert model.
8
+ */
9
+ export class DocumentAlertModel {
10
+ /**
11
+ * The unique identifier for the document alert.
12
+ * @type {string}
13
+ */
14
+ _id : string = SHARED.EMPTY
15
+
16
+ /**
17
+ * The alert status for the document.
18
+ * @type {string}
19
+ */
20
+ alertStatus?: string;
21
+
22
+ /**
23
+ * The context ID for the document.
24
+ * @type {?string}
25
+ */
26
+ contextId?: string;
27
+
28
+ /**
29
+ * The document ID for the document.
30
+ * @type {?string}
31
+ */
32
+ documentId?: string;
33
+
34
+ /**
35
+ * The alert message for the document.
36
+ * @type {?string}
37
+ */
38
+ alertMessage?:string;
39
+
40
+ /**
41
+ * The alert type for the document.
42
+ * @type {?string}
43
+ */
44
+ status?: string;
45
+ }
@@ -0,0 +1,44 @@
1
+
2
+ /**
3
+ * DocumentTypeModel
4
+ * @interface DocumentTypeModel Model for document types.
5
+ * @typedef {DocumentTypeModel} Model for document types.
6
+ */
7
+ export interface DocumentTypeModel {
8
+
9
+ /**
10
+ * The label for the document type.
11
+ * @type {string}
12
+ * @memberof DocumentTypeModel
13
+ */
14
+ label?: string,
15
+
16
+ /**
17
+ * The match rules for the document type.
18
+ * @type {string}
19
+ * @memberof DocumentTypeModel
20
+ */
21
+ matchRules?: string,
22
+
23
+ /**
24
+ * The name of the document type.
25
+ * @type {string}
26
+ * @memberof DocumentTypeModel
27
+ */
28
+ name?: string,
29
+
30
+
31
+ /**
32
+ * The parent document type ID.
33
+ * @type {string}
34
+ * @memberof DocumentTypeModel
35
+ */
36
+ parentDocumentTypeId?: string,
37
+
38
+ /**
39
+ * The document type ID.
40
+ * @type {string}
41
+ * @memberof DocumentTypeModel
42
+ */
43
+ _id: string
44
+ }
@@ -0,0 +1,53 @@
1
+ import { SHARED } from "../../../Shared/constant/SHARED";
2
+
3
+ /**
4
+ * Represents a document model.
5
+ *
6
+ * This class contains the structure for document-related data, including file name,
7
+ * status, and document URL.
8
+ */
9
+ export class DocumentModel {
10
+ /**
11
+ * The unique identifier for the document.
12
+ * @type {string}
13
+ */
14
+ _id: string = SHARED.EMPTY;
15
+
16
+ /**
17
+ * The name of the document file.
18
+ * @type {?string}
19
+ */
20
+ fileName?: string;
21
+
22
+ /**
23
+ * The current status of the document.
24
+ * @type {?string}
25
+ */
26
+ status?: string;
27
+
28
+ /**
29
+ * The URL where the document is hosted or stored.
30
+ * @type {?string}
31
+ */
32
+ documentUrl?: string;
33
+
34
+ /**
35
+ * Date of document get uploaded
36
+ * @type {?Date}
37
+ */
38
+ createdAt?: Date
39
+
40
+ /**
41
+ * Shows the type of document
42
+ * @type {?string}
43
+ */
44
+ documentTypeName?:string;
45
+
46
+ /**
47
+ * Shows the type of content
48
+ * @type {?string}
49
+ */
50
+ contentType?: string;
51
+
52
+ documentName?: string;
53
+ }
@@ -1,29 +1,35 @@
1
- /**
2
- * Represents the model for a folder block.
3
- *
4
- * This class provides the structure for folder block data, including properties
5
- * for ID, file counts, descriptive text, and counts for missing and pending files.
6
- */
7
- export declare class FolderBlockModel {
8
- /**
9
- * Unique identifier for the folder block.
10
- * Defaults to an empty string sourced from `SHARED.EMPTY`.
11
- */
12
- _id: string;
13
- /**
14
- * Total number of document within the folder block.
15
- */
16
- documentCount?: number;
17
- /**
18
- * Descriptive text associated with the folder block.
19
- */
20
- folderName?: string;
21
- /**
22
- * Number of files marked as missing in the folder block.
23
- */
24
- missingFiles?: number;
25
- /**
26
- * Number of files marked as pending in the folder block.
27
- */
28
- pendingFiles?: number;
29
- }
1
+ import { SHARED } from "../../../Shared/constant/SHARED";
2
+
3
+ /**
4
+ * Represents the model for a folder block.
5
+ *
6
+ * This class provides the structure for folder block data, including properties
7
+ * for ID, file counts, descriptive text, and counts for missing and pending files.
8
+ */
9
+ export class FolderBlockModel {
10
+ /**
11
+ * Unique identifier for the folder block.
12
+ * Defaults to an empty string sourced from `SHARED.EMPTY`.
13
+ */
14
+ _id: string = SHARED.EMPTY;
15
+
16
+ /**
17
+ * Total number of document within the folder block.
18
+ */
19
+ documentCount?: number;
20
+
21
+ /**
22
+ * Descriptive text associated with the folder block.
23
+ */
24
+ folderName?: string;
25
+
26
+ /**
27
+ * Number of files marked as missing in the folder block.
28
+ */
29
+ missingFiles?: number;
30
+
31
+ /**
32
+ * Number of files marked as pending in the folder block.
33
+ */
34
+ pendingFiles?: number;
35
+ }
@@ -0,0 +1,119 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
3
+ import { DocumentHttpService } from './document-http.service';
4
+ import { DocumentStore } from '../state/document.store';
5
+ import { AppConfigService } from '../../../Shared/services/app-config.service';
6
+ import { URLS } from '../../../Shared/constant/URLS';
7
+ import { DocumentTypeModel } from '../models/document-type.model';
8
+ import { throwError } from 'rxjs';
9
+ import { FolderBlockModel } from '../models/folder.model';
10
+ import { DocumentModel } from '../models/document.model';
11
+
12
+ describe('DocumentHttpService', () => {
13
+ let service: DocumentHttpService;
14
+ let httpMock: HttpTestingController;
15
+ let documentStoreSpy: jasmine.SpyObj<DocumentStore>;
16
+ let appConfigServiceSpy: jasmine.SpyObj<AppConfigService>;
17
+
18
+ beforeEach(() => {
19
+ documentStoreSpy = jasmine.createSpyObj('DocumentStore', ['setDocumentTypes', 'setFolders']);
20
+ appConfigServiceSpy = jasmine.createSpyObj('AppConfigService', ['apiBaseUrl'], {
21
+ apiBaseUrl: 'http://localhost/api'
22
+ });
23
+
24
+ TestBed.configureTestingModule({
25
+ imports: [HttpClientTestingModule],
26
+ providers: [
27
+ DocumentHttpService,
28
+ { provide: DocumentStore, useValue: documentStoreSpy },
29
+ { provide: AppConfigService, useValue: appConfigServiceSpy }
30
+ ]
31
+ });
32
+
33
+ service = TestBed.inject(DocumentHttpService);
34
+ httpMock = TestBed.inject(HttpTestingController);
35
+ });
36
+
37
+ it('should be created', () => {
38
+ expect(service).toBeTruthy();
39
+ });
40
+
41
+ it('should fetch document types and update the store', () => {
42
+ const mockDocumentTypes: DocumentTypeModel[] = [
43
+ {
44
+ _id: '1',
45
+ label: 'Parent-child1',
46
+ name: 'Type 1',
47
+ matchRules: 'Rule 1',
48
+ parentDocumentTypeId: '0'
49
+ },
50
+ {
51
+ _id: '2',
52
+ label: 'Parent-child2',
53
+ name: 'Type 2',
54
+ matchRules: 'Rule 2',
55
+ parentDocumentTypeId: '1'
56
+ }
57
+ ];
58
+
59
+ service.getDocumentTypes().subscribe((documentTypes) => {
60
+ expect(documentTypes).toEqual(mockDocumentTypes);
61
+ expect(documentStoreSpy.setDocumentTypes).toHaveBeenCalledWith(mockDocumentTypes);
62
+ });
63
+
64
+ const req = httpMock.expectOne(
65
+ `${appConfigServiceSpy.apiBaseUrl}${URLS.DOCUMENT_UPLOAD}/${URLS.DOCUMENT_TYPES}`
66
+ );
67
+ expect(req.request.method).toBe('GET');
68
+ req.flush(mockDocumentTypes); // Mock the response with data
69
+ });
70
+
71
+
72
+
73
+ it('should fetch folders data and update the store', () => {
74
+ const contextId = 'someContextId';
75
+ const mockFolderData: FolderBlockModel[] = [
76
+ { _id: '1', folderName: 'Folder 1' },
77
+ { _id: '2', folderName: 'Folder 2' }
78
+ ];
79
+
80
+ service.getFoldersData(contextId).subscribe((foldersData) => {
81
+ expect(foldersData).toEqual(mockFolderData);
82
+ expect(documentStoreSpy.setFolders).toHaveBeenCalledWith(mockFolderData); // ✅ Corrected method
83
+ });
84
+
85
+ const req = httpMock.expectOne(
86
+ `${appConfigServiceSpy.apiBaseUrl}${URLS.DOCUMENT_UPLOAD}${URLS.FOLDERS}${contextId}`
87
+ );
88
+ expect(req.request.method).toBe('GET');
89
+ req.flush(mockFolderData);
90
+ });
91
+
92
+ afterEach(() => {
93
+ httpMock.verify();
94
+ });
95
+
96
+ it('should update document name successfully', () => {
97
+ const documentId = '123';
98
+ const payload = { fileName: 'New Document Name' };
99
+ const mockUpdatedDocument: DocumentModel = {
100
+ _id: documentId,
101
+ fileName: 'New Document Name'
102
+ } as DocumentModel;
103
+
104
+ service.updateDocumentName(documentId, payload).subscribe((updatedDoc) => {
105
+ expect(updatedDoc).toEqual(jasmine.objectContaining(mockUpdatedDocument));
106
+ });
107
+
108
+ const req = httpMock.expectOne(
109
+ `${appConfigServiceSpy.apiBaseUrl}${URLS.DOCUMENT_UPLOAD}/${documentId}`
110
+ );
111
+ expect(req.request.method).toBe('PUT');
112
+ expect(req.request.body).toEqual(payload);
113
+ req.flush(mockUpdatedDocument);
114
+ });
115
+
116
+ afterEach(() => {
117
+ httpMock.verify();
118
+ });
119
+ });