Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { ArsStorageComponent } from './ars-storage.component';
import { ArsStorageService } from './ars-storage.service';
import { Observable } from 'rxjs/Observable';
import { ChartDataDetailModel } from './ars-storage.model';
import { Chart } from 'chart.js';
describe('ArsStorageComponent', () => {
let arsStorageService: ArsStorageService;
let arsStorageComponent: ArsStorageComponent;
beforeEach(() => {
arsStorageService = new ArsStorageService(null);
arsStorageComponent = new ArsStorageComponent(arsStorageService);
});
it('arsStorageComponent should be created', () => {
expect(arsStorageComponent).toBeTruthy();
});
it('should test ngOnInit', () => {
const createAttachmentStoragePieChartSpy = spyOn(
arsStorageComponent,
'createAttachmentStoragePieChart'
);
const createAttachmentStorageComboChartSpy = spyOn(
arsStorageComponent,
'createAttachmentStorageComboChart'
);
const createMetadataStoragePieChartSpy = spyOn(
arsStorageComponent,
'createMetadataStoragePieChart'
);
const createMetadataStorageComboChartSpy = spyOn(
arsStorageComponent,
'createMetadataStorageComboChart'
);
const getAttachmentDetailsSpy = spyOn(
arsStorageService,
'getAttachmentDetails'
).and.callFake(() => new Observable(observer => observer.unsubscribe()));
arsStorageComponent.ngOnInit();
expect(createAttachmentStoragePieChartSpy).toHaveBeenCalled();
expect(createAttachmentStorageComboChartSpy).toHaveBeenCalled();
expect(createMetadataStoragePieChartSpy).toHaveBeenCalled();
expect(createMetadataStorageComboChartSpy).toHaveBeenCalled();
expect(getAttachmentDetailsSpy).toHaveBeenCalled();
});
it('should get the attachment data details and meta data details successfully', () => {
const attachmentDetailsModel = new ChartDataDetailModel();
attachmentDetailsModel.availableStorage = 1;
attachmentDetailsModel.average = 1;
attachmentDetailsModel.averageAttachmentSize = 1;
attachmentDetailsModel.peakUsage = 1;
attachmentDetailsModel.totalAttachments = 1;
attachmentDetailsModel.totalStorage = 1;
attachmentDetailsModel.usedStorage = 1;
arsStorageComponent.attachmentStoragePieChart = {
update: () => {
return;
},
data: {
datasets: [
{
data: [1, 2]
}
]
}
};
arsStorageComponent.attachmentStorageComboChart = {
update: () => {
return;
},
data: {
datasets: [{ data: 1 }, { data: 2 }],
labels: ''
}
};
arsStorageComponent.metadataStoragePieChart = {
update: () => {
return;
},
data: {
datasets: [
{
data: [1, 2]
}
]
}
};
arsStorageComponent.metadataStorageComboChart = {
update: () => {
return;
},
data: {
datasets: [{ data: 1 }, { data: 2 }],
labels: ''
}
};
const createAttachmentStoragePieChartSpy = spyOn(
arsStorageComponent,
'createAttachmentStoragePieChart'
);
const createAttachmentStorageComboChartSpy = spyOn(
arsStorageComponent,
'createAttachmentStorageComboChart'
);
const createMetadataStoragePieChartSpy = spyOn(
arsStorageComponent,
'createMetadataStoragePieChart'
);
const createMetadataStorageComboChartSpy = spyOn(
arsStorageComponent,
'createMetadataStorageComboChart'
);
spyOn(arsStorageService, 'getMetadataDetails').and.callFake(
() => new Observable(observer => observer.next(attachmentDetailsModel))
);
const getAttachmentDetailsSpy = spyOn(
arsStorageService,
'getAttachmentDetails'
).and.callFake(() => {
return new Observable(observer => {
observer.next(attachmentDetailsModel);
observer.complete();
});
});
arsStorageComponent.ngOnInit();
expect(createAttachmentStoragePieChartSpy).toHaveBeenCalled();
expect(createAttachmentStorageComboChartSpy).toHaveBeenCalled();
expect(createMetadataStoragePieChartSpy).toHaveBeenCalled();
expect(createMetadataStorageComboChartSpy).toHaveBeenCalled();
expect(arsStorageComponent.attachmentDetails$).toBe(attachmentDetailsModel);
expect(arsStorageComponent.metadataDetails$).toBe(attachmentDetailsModel);
});
it('should define the attachmentStoragePieChart', () => {
arsStorageComponent.attachmentStorageCanvasLeft = { nativeElement: {} };
arsStorageComponent.createAttachmentStoragePieChart();
expect(arsStorageComponent.attachmentStoragePieChart).toBeDefined();
});
it('should define the createAttachmentStorageComboChart', () => {
arsStorageComponent.attachmentStorageCanvasRight = { nativeElement: {} };
arsStorageComponent.createAttachmentStorageComboChart();
expect(arsStorageComponent.attachmentStorageComboChart).toBeDefined();
});
it('should define the createMetadataStoragePieChart', () => {
arsStorageComponent.metadataStorageCanvasLeft = { nativeElement: {} };
arsStorageComponent.createMetadataStoragePieChart();
expect(arsStorageComponent.metadataStoragePieChart).toBeDefined();
});
it('should define the createMetadataStorageComboChart', () => {
arsStorageComponent.metadataStorageCanvasRight = { nativeElement: {} };
arsStorageComponent.createMetadataStorageComboChart();
expect(arsStorageComponent.metadataStorageComboChart).toBeDefined();
});
it('should test ngOnDestroy', () => {
expect(arsStorageComponent.subscription.unsubscribe).toBeTruthy();
});
});