cat-documents-ng 1.0.4 → 1.0.6
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/ng-package.json +10 -0
- package/package.json +5 -11
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +3 -0
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +13 -0
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +70 -0
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +133 -0
- package/src/Shared/components/table-primary/table-primary.component.html +66 -0
- package/src/Shared/components/table-primary/table-primary.component.scss +227 -0
- package/src/Shared/components/table-primary/table-primary.component.spec.ts +23 -0
- package/src/Shared/components/table-primary/table-primary.component.ts +143 -0
- package/src/Shared/components/table-primary/table-primary.model.ts +21 -0
- package/src/Shared/constant/ERROR.ts +55 -0
- package/src/Shared/constant/PERMISSIONS.ts +17 -0
- package/src/Shared/constant/SHARED.ts +936 -0
- package/{Shared/constant/URLS.d.ts → src/Shared/constant/URLS.ts} +31 -25
- package/src/Shared/services/app-config.service.spec.ts +19 -0
- package/src/Shared/services/app-config.service.ts +73 -0
- package/{Shared/services/global-error.handler.d.ts → src/Shared/services/global-error.handler.ts} +11 -9
- package/src/Shared/services/session.service.spec.ts +16 -0
- package/src/Shared/services/session.service.ts +76 -0
- package/src/Shared/shared.module.ts +25 -0
- package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +1 -0
- package/src/lib/document/components/document-actions/document-actions.component.html +59 -0
- package/src/lib/document/components/document-actions/document-actions.component.scss +362 -0
- package/src/lib/document/components/document-actions/document-actions.component.spec.ts +297 -0
- package/src/lib/document/components/document-actions/document-actions.component.ts +163 -0
- package/src/lib/document/components/document-container/document-container.component.html +36 -0
- package/src/lib/document/components/document-container/document-container.component.scss +144 -0
- package/src/lib/document/components/document-container/document-container.component.spec.ts +110 -0
- package/src/lib/document/components/document-container/document-container.component.ts +363 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +332 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +1877 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +258 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +664 -0
- package/src/lib/document/components/document-history/document-history.component.html +96 -0
- package/src/lib/document/components/document-history/document-history.component.scss +392 -0
- package/src/lib/document/components/document-history/document-history.component.spec.ts +93 -0
- package/src/lib/document/components/document-history/document-history.component.ts +373 -0
- package/src/lib/document/components/document-list/document-list.component.html +46 -0
- package/src/lib/document/components/document-list/document-list.component.scss +513 -0
- package/src/lib/document/components/document-list/document-list.component.spec.ts +486 -0
- package/src/lib/document/components/document-list/document-list.component.ts +682 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.html +36 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.scss +34 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +75 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
- package/src/lib/document/components/document-search/document-search.component.html +64 -0
- package/src/lib/document/components/document-search/document-search.component.scss +206 -0
- package/src/lib/document/components/document-search/document-search.component.spec.ts +82 -0
- package/src/lib/document/components/document-search/document-search.component.ts +163 -0
- package/src/lib/document/components/document-status/document-status.component.html +31 -0
- package/src/lib/document/components/document-status/document-status.component.scss +192 -0
- package/src/lib/document/components/document-status/document-status.component.spec.ts +23 -0
- package/src/lib/document/components/document-status/document-status.component.ts +87 -0
- package/src/lib/document/components/document-upload/document-upload.component.html +160 -0
- package/src/lib/document/components/document-upload/document-upload.component.scss +235 -0
- package/src/lib/document/components/document-upload/document-upload.component.spec.ts +95 -0
- package/src/lib/document/components/document-upload/document-upload.component.ts +668 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.html +50 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.scss +187 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +79 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.ts +261 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +48 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +320 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +59 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +150 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.html +44 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.scss +363 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +23 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.ts +316 -0
- package/src/lib/document/components/folder-block/folder-block.component.html +46 -0
- package/src/lib/document/components/folder-block/folder-block.component.scss +9 -0
- package/src/lib/document/components/folder-block/folder-block.component.spec.ts +70 -0
- package/{lib/document/components/folder-block/folder-block.component.d.ts → src/lib/document/components/folder-block/folder-block.component.ts} +28 -12
- package/src/lib/document/components/folder-container/folder-container.component.html +56 -0
- package/src/lib/document/components/folder-container/folder-container.component.scss +20 -0
- package/src/lib/document/components/folder-container/folder-container.component.spec.ts +27 -0
- package/src/lib/document/components/folder-container/folder-container.component.ts +328 -0
- package/src/lib/document/components/linked-document/linked-document.component.html +23 -0
- package/src/lib/document/components/linked-document/linked-document.component.scss +10 -0
- package/src/lib/document/components/linked-document/linked-document.component.spec.ts +61 -0
- package/src/lib/document/components/linked-document/linked-document.component.ts +49 -0
- package/src/lib/document/components/request-document/request-document.component.html +86 -0
- package/src/lib/document/components/request-document/request-document.component.scss +16 -0
- package/src/lib/document/components/request-document/request-document.component.ts +278 -0
- package/src/lib/document/components/sidebar/sidebar.component.html +75 -0
- package/src/lib/document/components/sidebar/sidebar.component.scss +157 -0
- package/src/lib/document/components/sidebar/sidebar.component.spec.ts +114 -0
- package/src/lib/document/components/sidebar/sidebar.component.ts +223 -0
- package/src/lib/document/components/user-list/user-list.component.html +33 -0
- package/src/lib/document/components/user-list/user-list.component.scss +118 -0
- package/src/lib/document/components/user-list/user-list.component.spec.ts +23 -0
- package/src/lib/document/components/user-list/user-list.component.ts +181 -0
- package/src/lib/document/constant/DOCUMENT_HISTORY.ts +52 -0
- package/src/lib/document/directives/document.directive.ts +32 -0
- package/src/lib/document/directives/permission.directive.spec.ts +0 -0
- package/src/lib/document/directives/permission.directive.ts +72 -0
- package/src/lib/document/document.module.ts +351 -0
- package/{lib/document/models/document-alert.model.d.ts → src/lib/document/models/document-alert.model.ts} +11 -4
- package/src/lib/document/models/document-category.model.ts +30 -0
- package/src/lib/document/models/document-history.model.ts +109 -0
- package/src/lib/document/models/document-list-response.model.ts +37 -0
- package/src/lib/document/models/document-type.model.ts +44 -0
- package/src/lib/document/models/document.model.ts +53 -0
- package/{lib/document/models/folder.model.d.ts → src/lib/document/models/folder.model.ts} +10 -4
- package/src/lib/document/models/status-data.model.ts +31 -0
- package/src/lib/document/models/uploaded-file-response.model.ts +7 -0
- package/src/lib/document/models/user-list.model.ts +10 -0
- package/src/lib/document/services/csv-parser.service.spec.ts +97 -0
- package/src/lib/document/services/csv-parser.service.ts +303 -0
- package/src/lib/document/services/document-actions.service.ts +125 -0
- package/src/lib/document/services/document-content-type.service.ts +193 -0
- package/src/lib/document/services/document-history-style.service.ts +138 -0
- package/src/lib/document/services/document-history.service.ts +129 -0
- package/src/lib/document/services/document-http.service.spec.ts +119 -0
- package/src/lib/document/services/document-http.service.ts +497 -0
- package/src/lib/document/services/document-list.service.ts +195 -0
- package/src/lib/document/services/document-menu.service.ts +277 -0
- package/src/lib/document/services/document-scroll.service.ts +138 -0
- package/src/lib/document/services/document-severity.service.ts +98 -0
- package/src/lib/document/services/document-table-builder.service.ts +82 -0
- package/src/lib/document/services/document-upload-business.service.ts +326 -0
- package/src/lib/document/services/document-upload-data.service.ts +82 -0
- package/src/lib/document/services/document-upload-form.service.ts +149 -0
- package/src/lib/document/services/document-upload.service.spec.ts +99 -0
- package/src/lib/document/services/document-upload.service.ts +209 -0
- package/src/lib/document/services/document-viewer.service.ts +279 -0
- package/src/lib/document/services/document-zoom.service.spec.ts +56 -0
- package/src/lib/document/services/document-zoom.service.ts +164 -0
- package/src/lib/document/services/document.service.ts +356 -0
- package/src/lib/document/services/eml-parser.service.ts +444 -0
- package/src/lib/document/services/excel-parser.service.spec.ts +66 -0
- package/src/lib/document/services/excel-parser.service.ts +483 -0
- package/src/lib/document/services/file-format.service.spec.ts +16 -0
- package/src/lib/document/services/file-format.service.ts +63 -0
- package/src/lib/document/services/status-calculator.service.ts +44 -0
- package/src/lib/document/services/user-list.service.ts +77 -0
- package/src/lib/document/state/document.query.ts +378 -0
- package/{lib/document/state/document.service.d.ts → src/lib/document/state/document.service.ts} +46 -15
- package/src/lib/document/state/document.state.ts +100 -0
- package/src/lib/document/state/document.store.ts +200 -0
- package/{public-api.d.ts → src/public-api.ts} +4 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +0 -44
- package/Shared/components/table-primary/table-primary.component.d.ts +0 -31
- package/Shared/components/table-primary/table-primary.model.d.ts +0 -19
- package/Shared/constant/ERROR.d.ts +0 -52
- package/Shared/constant/SHARED.d.ts +0 -546
- package/Shared/services/app-config.service.d.ts +0 -51
- package/Shared/services/session.service.d.ts +0 -46
- package/Shared/shared.module.d.ts +0 -14
- package/fesm2022/cat-documents-ng.mjs +0 -11392
- package/fesm2022/cat-documents-ng.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/document/components/document-actions/document-actions.component.d.ts +0 -78
- package/lib/document/components/document-container/document-container.component.d.ts +0 -162
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +0 -291
- package/lib/document/components/document-history/document-history.component.d.ts +0 -160
- package/lib/document/components/document-list/document-list.component.d.ts +0 -299
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +0 -28
- package/lib/document/components/document-search/document-search.component.d.ts +0 -77
- package/lib/document/components/document-status/document-status.component.d.ts +0 -24
- package/lib/document/components/document-upload/document-upload.component.d.ts +0 -321
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +0 -137
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +0 -33
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +0 -110
- package/lib/document/components/folder-container/folder-container.component.d.ts +0 -162
- package/lib/document/components/linked-document/linked-document.component.d.ts +0 -39
- package/lib/document/components/request-document/request-document.component.d.ts +0 -69
- package/lib/document/components/sidebar/sidebar.component.d.ts +0 -109
- package/lib/document/components/user-list/user-list.component.d.ts +0 -34
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +0 -41
- package/lib/document/directives/document.directive.d.ts +0 -20
- package/lib/document/directives/permission.directive.d.ts +0 -38
- package/lib/document/document.module.d.ts +0 -60
- package/lib/document/models/document-category.model.d.ts +0 -24
- package/lib/document/models/document-history.model.d.ts +0 -94
- package/lib/document/models/document-list-response.model.d.ts +0 -33
- package/lib/document/models/document-type.model.d.ts +0 -37
- package/lib/document/models/document.model.d.ts +0 -44
- package/lib/document/models/status-data.model.d.ts +0 -27
- package/lib/document/models/uploaded-file-response.model.d.ts +0 -7
- package/lib/document/models/user-list.model.d.ts +0 -8
- package/lib/document/services/csv-parser.service.d.ts +0 -88
- package/lib/document/services/document-actions.service.d.ts +0 -48
- package/lib/document/services/document-content-type.service.d.ts +0 -85
- package/lib/document/services/document-history-style.service.d.ts +0 -34
- package/lib/document/services/document-history.service.d.ts +0 -42
- package/lib/document/services/document-http.service.d.ts +0 -179
- package/lib/document/services/document-list.service.d.ts +0 -74
- package/lib/document/services/document-menu.service.d.ts +0 -122
- package/lib/document/services/document-scroll.service.d.ts +0 -55
- package/lib/document/services/document-table-builder.service.d.ts +0 -38
- package/lib/document/services/document-upload-business.service.d.ts +0 -107
- package/lib/document/services/document-upload-data.service.d.ts +0 -40
- package/lib/document/services/document-upload-form.service.d.ts +0 -41
- package/lib/document/services/document-upload.service.d.ts +0 -99
- package/lib/document/services/document-viewer.service.d.ts +0 -97
- package/lib/document/services/document-zoom.service.d.ts +0 -81
- package/lib/document/services/document.service.d.ts +0 -161
- package/lib/document/services/eml-parser.service.d.ts +0 -116
- package/lib/document/services/excel-parser.service.d.ts +0 -169
- package/lib/document/services/file-format.service.d.ts +0 -34
- package/lib/document/services/status-calculator.service.d.ts +0 -20
- package/lib/document/services/user-list.service.d.ts +0 -29
- package/lib/document/state/document.query.d.ts +0 -243
- package/lib/document/state/document.state.d.ts +0 -61
- package/lib/document/state/document.store.d.ts +0 -56
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { DocumentContentViewerComponent } from './document-content-viewer.component';
|
|
3
|
+
import { PdfViewerModule } from 'ng2-pdf-viewer';
|
|
4
|
+
import { ButtonModule } from 'primeng/button';
|
|
5
|
+
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|
6
|
+
import { ExcelParserService } from '../../services/excel-parser.service';
|
|
7
|
+
import { of, throwError } from 'rxjs';
|
|
8
|
+
|
|
9
|
+
describe('DocumentContentViewerComponent', () => {
|
|
10
|
+
let component: DocumentContentViewerComponent;
|
|
11
|
+
let fixture: ComponentFixture<DocumentContentViewerComponent>;
|
|
12
|
+
let mockExcelParserService: jasmine.SpyObj<ExcelParserService>;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
const excelParserSpy = jasmine.createSpyObj('ExcelParserService', [
|
|
16
|
+
'parseExcelData',
|
|
17
|
+
'ensureDataConsistency',
|
|
18
|
+
'convertToLegacyFormat',
|
|
19
|
+
'parseSheetData'
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
await TestBed.configureTestingModule({
|
|
23
|
+
imports: [
|
|
24
|
+
PdfViewerModule,
|
|
25
|
+
ButtonModule,
|
|
26
|
+
HttpClientTestingModule
|
|
27
|
+
],
|
|
28
|
+
declarations: [ DocumentContentViewerComponent ],
|
|
29
|
+
providers: [
|
|
30
|
+
{ provide: ExcelParserService, useValue: excelParserSpy }
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
.compileComponents();
|
|
34
|
+
|
|
35
|
+
mockExcelParserService = TestBed.inject(ExcelParserService) as jasmine.SpyObj<ExcelParserService>;
|
|
36
|
+
|
|
37
|
+
fixture = TestBed.createComponent(DocumentContentViewerComponent);
|
|
38
|
+
component = fixture.componentInstance;
|
|
39
|
+
fixture.detectChanges();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should create', () => {
|
|
43
|
+
expect(component).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should detect PDF content type correctly', () => {
|
|
47
|
+
component.contentType = 'application/pdf';
|
|
48
|
+
expect(component.isPdf).toBe(true);
|
|
49
|
+
expect(component.isImage).toBe(false);
|
|
50
|
+
expect(component.isExcel).toBe(false);
|
|
51
|
+
expect(component.isWord).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should detect image content types correctly', () => {
|
|
55
|
+
component.contentType = 'image/png';
|
|
56
|
+
expect(component.isImage).toBe(true);
|
|
57
|
+
expect(component.isPdf).toBe(false);
|
|
58
|
+
expect(component.isExcel).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should detect Excel content types correctly', () => {
|
|
62
|
+
component.contentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
63
|
+
expect(component.isExcel).toBe(true);
|
|
64
|
+
expect(component.isPdf).toBe(false);
|
|
65
|
+
expect(component.isImage).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should detect Word content types correctly', () => {
|
|
69
|
+
component.contentType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
70
|
+
expect(component.isWord).toBe(true);
|
|
71
|
+
expect(component.isPdf).toBe(false);
|
|
72
|
+
expect(component.isImage).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should detect CSV content type correctly', () => {
|
|
76
|
+
component.contentType = 'text/csv';
|
|
77
|
+
expect(component.isCsv).toBe(true);
|
|
78
|
+
expect(component.isPdf).toBe(false);
|
|
79
|
+
expect(component.isImage).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should detect email content types correctly', () => {
|
|
83
|
+
component.contentType = 'message/rfc822';
|
|
84
|
+
expect(component.isEmail).toBe(true);
|
|
85
|
+
expect(component.isPdf).toBe(false);
|
|
86
|
+
expect(component.isImage).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should detect OpenDocument content type correctly', () => {
|
|
90
|
+
component.contentType = 'application/vnd.oasis.opendocument.text';
|
|
91
|
+
expect(component.isOpenDocument).toBe(true);
|
|
92
|
+
expect(component.isPdf).toBe(false);
|
|
93
|
+
expect(component.isImage).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should return correct document icon for PDF', () => {
|
|
97
|
+
component.contentType = 'application/pdf';
|
|
98
|
+
expect(component.documentIcon).toBe('pi pi-file-pdf');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should return correct document icon for image', () => {
|
|
102
|
+
component.contentType = 'image/png';
|
|
103
|
+
expect(component.documentIcon).toBe('pi pi-image');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should return correct document icon for Excel', () => {
|
|
107
|
+
component.contentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
108
|
+
expect(component.documentIcon).toBe('pi pi-file-excel');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should return correct document type text for PDF', () => {
|
|
112
|
+
component.contentType = 'application/pdf';
|
|
113
|
+
expect(component.documentTypeText).toBe('PDF Document');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should return correct document type text for image', () => {
|
|
117
|
+
component.contentType = 'image/png';
|
|
118
|
+
expect(component.documentTypeText).toBe('Image');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should handle unsupported content types correctly', () => {
|
|
122
|
+
component.contentType = 'application/unknown';
|
|
123
|
+
expect(component.isUnsupported).toBe(true);
|
|
124
|
+
expect(component.isPdf).toBe(false);
|
|
125
|
+
expect(component.isImage).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should handle undefined content type correctly', () => {
|
|
129
|
+
component.contentType = undefined;
|
|
130
|
+
expect(component.isPdf).toBe(false);
|
|
131
|
+
expect(component.isImage).toBe(false);
|
|
132
|
+
expect(component.isExcel).toBe(false);
|
|
133
|
+
expect(component.isWord).toBe(false);
|
|
134
|
+
expect(component.isCsv).toBe(false);
|
|
135
|
+
expect(component.isEmail).toBe(false);
|
|
136
|
+
expect(component.isOpenDocument).toBe(false);
|
|
137
|
+
expect(component.isUnsupported).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should handle download document correctly', () => {
|
|
141
|
+
spyOn(document, 'createElement').and.returnValue({
|
|
142
|
+
href: '',
|
|
143
|
+
download: '',
|
|
144
|
+
target: '',
|
|
145
|
+
click: jasmine.createSpy('click')
|
|
146
|
+
} as any);
|
|
147
|
+
spyOn(document.body, 'appendChild');
|
|
148
|
+
spyOn(document.body, 'removeChild');
|
|
149
|
+
|
|
150
|
+
component.documentUrl = 'http://example.com/test.pdf';
|
|
151
|
+
component.documentName = 'test.pdf';
|
|
152
|
+
component.downloadDocument();
|
|
153
|
+
|
|
154
|
+
expect(document.createElement).toHaveBeenCalledWith('a');
|
|
155
|
+
expect(document.body.appendChild).toHaveBeenCalled();
|
|
156
|
+
expect(document.body.removeChild).toHaveBeenCalled();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should handle open in new tab correctly', () => {
|
|
160
|
+
spyOn(window, 'open');
|
|
161
|
+
component.documentUrl = 'http://example.com/test.pdf';
|
|
162
|
+
component.openInNewTab();
|
|
163
|
+
|
|
164
|
+
expect(window.open).toHaveBeenCalledWith('http://example.com/test.pdf', '_blank');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should not call download when documentUrl is undefined', () => {
|
|
168
|
+
spyOn(document, 'createElement');
|
|
169
|
+
component.documentUrl = undefined;
|
|
170
|
+
component.downloadDocument();
|
|
171
|
+
|
|
172
|
+
expect(document.createElement).not.toHaveBeenCalled();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should not call open in new tab when documentUrl is undefined', () => {
|
|
176
|
+
spyOn(window, 'open');
|
|
177
|
+
component.documentUrl = undefined;
|
|
178
|
+
component.openInNewTab();
|
|
179
|
+
|
|
180
|
+
expect(window.open).not.toHaveBeenCalled();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should initialize Excel data loading on init', () => {
|
|
184
|
+
component.contentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
185
|
+
component.documentUrl = 'http://example.com/test.xlsx';
|
|
186
|
+
component.ngOnInit();
|
|
187
|
+
|
|
188
|
+
expect(component.isLoadingExcel).toBe(true);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should handle Excel content type changes', () => {
|
|
192
|
+
component.contentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
193
|
+
component.documentUrl = 'http://example.com/test.xlsx';
|
|
194
|
+
component.ngOnChanges({
|
|
195
|
+
contentType: { currentValue: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', previousValue: undefined, firstChange: true, isFirstChange: () => true }
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
expect(component.isLoadingExcel).toBe(true);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('should reset Excel data when content type changes to non-Excel', () => {
|
|
202
|
+
component.contentType = 'application/pdf';
|
|
203
|
+
component.ngOnChanges({
|
|
204
|
+
contentType: { currentValue: 'application/pdf', previousValue: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', firstChange: false, isFirstChange: () => false }
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(component.excelData).toBeNull();
|
|
208
|
+
expect(component.excelTableData).toEqual([]);
|
|
209
|
+
expect(component.excelSheets).toEqual([]);
|
|
210
|
+
expect(component.currentSheet).toBe('');
|
|
211
|
+
expect(component.isLoadingExcel).toBe(false);
|
|
212
|
+
expect(component.excelError).toBeNull();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should change Excel sheet correctly', () => {
|
|
216
|
+
component.excelSheets = ['Sheet1', 'Sheet2'];
|
|
217
|
+
component.currentSheet = 'Sheet1';
|
|
218
|
+
component.excelTableData = [['Header'], ['Data']];
|
|
219
|
+
|
|
220
|
+
// Mock the service methods
|
|
221
|
+
mockExcelParserService.parseSheetData.and.returnValue([]);
|
|
222
|
+
mockExcelParserService.ensureDataConsistency.and.returnValue([]);
|
|
223
|
+
mockExcelParserService.convertToLegacyFormat.and.returnValue([]);
|
|
224
|
+
|
|
225
|
+
component.changeSheet('Sheet2');
|
|
226
|
+
|
|
227
|
+
expect(component.currentSheet).toBe('Sheet2');
|
|
228
|
+
expect(mockExcelParserService.parseSheetData).toHaveBeenCalled();
|
|
229
|
+
expect(mockExcelParserService.ensureDataConsistency).toHaveBeenCalled();
|
|
230
|
+
expect(mockExcelParserService.convertToLegacyFormat).toHaveBeenCalled();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('should return safe Excel styled data when data is available', () => {
|
|
234
|
+
component.excelStyledData = [
|
|
235
|
+
{ cells: [{ value: 'Test Data' }] }
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
expect(component.safeExcelStyledData).toEqual([
|
|
239
|
+
{ cells: [{ value: 'Test Data' }] }
|
|
240
|
+
]);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('should return default data when Excel styled data is empty', () => {
|
|
244
|
+
component.excelStyledData = [];
|
|
245
|
+
|
|
246
|
+
expect(component.safeExcelStyledData).toEqual([
|
|
247
|
+
{ cells: [{ value: 'No data available' }] }
|
|
248
|
+
]);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('should return default data when Excel styled data is null', () => {
|
|
252
|
+
component.excelStyledData = null as any;
|
|
253
|
+
|
|
254
|
+
expect(component.safeExcelStyledData).toEqual([
|
|
255
|
+
{ cells: [{ value: 'No data available' }] }
|
|
256
|
+
]);
|
|
257
|
+
});
|
|
258
|
+
});
|