cat-documents-ng 1.0.6 → 1.0.7
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/README.md +322 -322
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +44 -0
- package/Shared/components/table-primary/table-primary.component.d.ts +31 -0
- package/Shared/components/table-primary/table-primary.model.d.ts +19 -0
- package/Shared/constant/ERROR.d.ts +52 -0
- package/Shared/constant/SHARED.d.ts +546 -0
- package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +25 -31
- package/Shared/services/app-config.service.d.ts +51 -0
- package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +9 -11
- package/Shared/services/session.service.d.ts +46 -0
- package/Shared/shared.module.d.ts +14 -0
- package/fesm2022/cat-documents-ng.mjs +11405 -0
- package/fesm2022/cat-documents-ng.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/document/components/document-actions/document-actions.component.d.ts +78 -0
- package/lib/document/components/document-container/document-container.component.d.ts +162 -0
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +291 -0
- package/lib/document/components/document-history/document-history.component.d.ts +160 -0
- package/lib/document/components/document-list/document-list.component.d.ts +299 -0
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
- package/lib/document/components/document-search/document-search.component.d.ts +77 -0
- package/lib/document/components/document-status/document-status.component.d.ts +24 -0
- package/lib/document/components/document-upload/document-upload.component.d.ts +321 -0
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +137 -0
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +33 -0
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +110 -0
- package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +12 -28
- package/lib/document/components/folder-container/folder-container.component.d.ts +162 -0
- package/lib/document/components/linked-document/linked-document.component.d.ts +39 -0
- package/lib/document/components/request-document/request-document.component.d.ts +69 -0
- package/lib/document/components/sidebar/sidebar.component.d.ts +109 -0
- package/lib/document/components/user-list/user-list.component.d.ts +34 -0
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +41 -0
- package/lib/document/directives/document.directive.d.ts +20 -0
- package/lib/document/directives/permission.directive.d.ts +38 -0
- package/lib/document/document.module.d.ts +60 -0
- package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +4 -11
- package/lib/document/models/document-category.model.d.ts +24 -0
- package/lib/document/models/document-history.model.d.ts +94 -0
- package/lib/document/models/document-list-response.model.d.ts +33 -0
- package/lib/document/models/document-type.model.d.ts +37 -0
- package/lib/document/models/document.model.d.ts +44 -0
- package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +4 -10
- package/lib/document/models/status-data.model.d.ts +27 -0
- package/lib/document/models/uploaded-file-response.model.d.ts +7 -0
- package/lib/document/models/user-list.model.d.ts +8 -0
- package/lib/document/services/csv-parser.service.d.ts +88 -0
- package/lib/document/services/document-actions.service.d.ts +48 -0
- package/lib/document/services/document-content-type.service.d.ts +85 -0
- package/lib/document/services/document-history-style.service.d.ts +34 -0
- package/lib/document/services/document-history.service.d.ts +42 -0
- package/lib/document/services/document-http.service.d.ts +179 -0
- package/lib/document/services/document-list.service.d.ts +74 -0
- package/lib/document/services/document-menu.service.d.ts +122 -0
- package/lib/document/services/document-scroll.service.d.ts +55 -0
- package/lib/document/services/document-table-builder.service.d.ts +38 -0
- package/lib/document/services/document-upload-business.service.d.ts +107 -0
- package/lib/document/services/document-upload-data.service.d.ts +40 -0
- package/lib/document/services/document-upload-form.service.d.ts +41 -0
- package/lib/document/services/document-upload.service.d.ts +99 -0
- package/lib/document/services/document-viewer.service.d.ts +97 -0
- package/lib/document/services/document-zoom.service.d.ts +81 -0
- package/lib/document/services/document.service.d.ts +161 -0
- package/lib/document/services/eml-parser.service.d.ts +116 -0
- package/lib/document/services/excel-parser.service.d.ts +169 -0
- package/lib/document/services/file-format.service.d.ts +34 -0
- package/lib/document/services/status-calculator.service.d.ts +20 -0
- package/lib/document/services/user-list.service.d.ts +29 -0
- package/lib/document/state/document.query.d.ts +243 -0
- package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +15 -46
- package/lib/document/state/document.state.d.ts +61 -0
- package/lib/document/state/document.store.d.ts +56 -0
- package/package.json +11 -5
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/ng-package.json +0 -10
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +0 -3
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +0 -13
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -70
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +0 -133
- package/src/Shared/components/table-primary/table-primary.component.html +0 -66
- package/src/Shared/components/table-primary/table-primary.component.scss +0 -227
- package/src/Shared/components/table-primary/table-primary.component.spec.ts +0 -23
- package/src/Shared/components/table-primary/table-primary.component.ts +0 -143
- package/src/Shared/components/table-primary/table-primary.model.ts +0 -21
- package/src/Shared/constant/ERROR.ts +0 -55
- package/src/Shared/constant/PERMISSIONS.ts +0 -17
- package/src/Shared/constant/SHARED.ts +0 -936
- package/src/Shared/services/app-config.service.spec.ts +0 -19
- package/src/Shared/services/app-config.service.ts +0 -73
- package/src/Shared/services/session.service.spec.ts +0 -16
- package/src/Shared/services/session.service.ts +0 -76
- package/src/Shared/shared.module.ts +0 -25
- package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +0 -1
- package/src/lib/document/components/document-actions/document-actions.component.html +0 -59
- package/src/lib/document/components/document-actions/document-actions.component.scss +0 -362
- package/src/lib/document/components/document-actions/document-actions.component.spec.ts +0 -297
- package/src/lib/document/components/document-actions/document-actions.component.ts +0 -163
- package/src/lib/document/components/document-container/document-container.component.html +0 -36
- package/src/lib/document/components/document-container/document-container.component.scss +0 -144
- package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
- package/src/lib/document/components/document-container/document-container.component.ts +0 -363
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +0 -332
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +0 -1877
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +0 -258
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +0 -664
- package/src/lib/document/components/document-history/document-history.component.html +0 -96
- package/src/lib/document/components/document-history/document-history.component.scss +0 -392
- package/src/lib/document/components/document-history/document-history.component.spec.ts +0 -93
- package/src/lib/document/components/document-history/document-history.component.ts +0 -373
- package/src/lib/document/components/document-list/document-list.component.html +0 -46
- package/src/lib/document/components/document-list/document-list.component.scss +0 -513
- package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -486
- package/src/lib/document/components/document-list/document-list.component.ts +0 -682
- package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
- package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
- package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
- package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
- package/src/lib/document/components/document-search/document-search.component.html +0 -64
- package/src/lib/document/components/document-search/document-search.component.scss +0 -206
- package/src/lib/document/components/document-search/document-search.component.spec.ts +0 -82
- package/src/lib/document/components/document-search/document-search.component.ts +0 -163
- package/src/lib/document/components/document-status/document-status.component.html +0 -31
- package/src/lib/document/components/document-status/document-status.component.scss +0 -192
- package/src/lib/document/components/document-status/document-status.component.spec.ts +0 -23
- package/src/lib/document/components/document-status/document-status.component.ts +0 -87
- package/src/lib/document/components/document-upload/document-upload.component.html +0 -160
- package/src/lib/document/components/document-upload/document-upload.component.scss +0 -235
- package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
- package/src/lib/document/components/document-upload/document-upload.component.ts +0 -668
- package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -50
- package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -187
- package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
- package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -261
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +0 -48
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +0 -320
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +0 -59
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +0 -150
- package/src/lib/document/components/documents-menu/documents-menu.component.html +0 -44
- package/src/lib/document/components/documents-menu/documents-menu.component.scss +0 -363
- package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +0 -23
- package/src/lib/document/components/documents-menu/documents-menu.component.ts +0 -316
- package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
- package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
- package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
- package/src/lib/document/components/folder-container/folder-container.component.html +0 -56
- package/src/lib/document/components/folder-container/folder-container.component.scss +0 -20
- package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
- package/src/lib/document/components/folder-container/folder-container.component.ts +0 -328
- package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
- package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
- package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
- package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
- package/src/lib/document/components/request-document/request-document.component.html +0 -86
- package/src/lib/document/components/request-document/request-document.component.scss +0 -16
- package/src/lib/document/components/request-document/request-document.component.ts +0 -278
- package/src/lib/document/components/sidebar/sidebar.component.html +0 -75
- package/src/lib/document/components/sidebar/sidebar.component.scss +0 -157
- package/src/lib/document/components/sidebar/sidebar.component.spec.ts +0 -114
- package/src/lib/document/components/sidebar/sidebar.component.ts +0 -223
- package/src/lib/document/components/user-list/user-list.component.html +0 -33
- package/src/lib/document/components/user-list/user-list.component.scss +0 -118
- package/src/lib/document/components/user-list/user-list.component.spec.ts +0 -23
- package/src/lib/document/components/user-list/user-list.component.ts +0 -181
- package/src/lib/document/constant/DOCUMENT_HISTORY.ts +0 -52
- package/src/lib/document/directives/document.directive.ts +0 -32
- package/src/lib/document/directives/permission.directive.spec.ts +0 -0
- package/src/lib/document/directives/permission.directive.ts +0 -72
- package/src/lib/document/document.module.ts +0 -351
- package/src/lib/document/models/document-category.model.ts +0 -30
- package/src/lib/document/models/document-history.model.ts +0 -109
- package/src/lib/document/models/document-list-response.model.ts +0 -37
- package/src/lib/document/models/document-type.model.ts +0 -44
- package/src/lib/document/models/document.model.ts +0 -53
- package/src/lib/document/models/status-data.model.ts +0 -31
- package/src/lib/document/models/uploaded-file-response.model.ts +0 -7
- package/src/lib/document/models/user-list.model.ts +0 -10
- package/src/lib/document/services/csv-parser.service.spec.ts +0 -97
- package/src/lib/document/services/csv-parser.service.ts +0 -303
- package/src/lib/document/services/document-actions.service.ts +0 -125
- package/src/lib/document/services/document-content-type.service.ts +0 -193
- package/src/lib/document/services/document-history-style.service.ts +0 -138
- package/src/lib/document/services/document-history.service.ts +0 -129
- package/src/lib/document/services/document-http.service.spec.ts +0 -119
- package/src/lib/document/services/document-http.service.ts +0 -497
- package/src/lib/document/services/document-list.service.ts +0 -195
- package/src/lib/document/services/document-menu.service.ts +0 -277
- package/src/lib/document/services/document-scroll.service.ts +0 -138
- package/src/lib/document/services/document-severity.service.ts +0 -98
- package/src/lib/document/services/document-table-builder.service.ts +0 -82
- package/src/lib/document/services/document-upload-business.service.ts +0 -326
- package/src/lib/document/services/document-upload-data.service.ts +0 -82
- package/src/lib/document/services/document-upload-form.service.ts +0 -149
- package/src/lib/document/services/document-upload.service.spec.ts +0 -99
- package/src/lib/document/services/document-upload.service.ts +0 -209
- package/src/lib/document/services/document-viewer.service.ts +0 -279
- package/src/lib/document/services/document-zoom.service.spec.ts +0 -56
- package/src/lib/document/services/document-zoom.service.ts +0 -164
- package/src/lib/document/services/document.service.ts +0 -356
- package/src/lib/document/services/eml-parser.service.ts +0 -444
- package/src/lib/document/services/excel-parser.service.spec.ts +0 -66
- package/src/lib/document/services/excel-parser.service.ts +0 -483
- package/src/lib/document/services/file-format.service.spec.ts +0 -16
- package/src/lib/document/services/file-format.service.ts +0 -63
- package/src/lib/document/services/status-calculator.service.ts +0 -44
- package/src/lib/document/services/user-list.service.ts +0 -77
- package/src/lib/document/state/document.query.ts +0 -378
- package/src/lib/document/state/document.state.ts +0 -100
- package/src/lib/document/state/document.store.ts +0 -200
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -1,258 +0,0 @@
|
|
|
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
|
-
});
|