mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Fix user info unit test (#4887)
* fix unit test user info component * fix unit test user info component * replace download call with spy * fix karma conf
This commit is contained in:
@@ -22,7 +22,7 @@ import { DownloadZipDialogComponent } from './download-zip.dialog';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { DownloadZipService } from '../services/download-zip.service';
|
||||
import { of } from 'rxjs';
|
||||
import { Observable } from 'rxjs/index';
|
||||
|
||||
describe('DownloadZipDialogComponent', () => {
|
||||
|
||||
@@ -40,17 +40,6 @@ describe('DownloadZipDialogComponent', () => {
|
||||
]
|
||||
};
|
||||
|
||||
const pendingDownloadEntry = {
|
||||
entry: {
|
||||
bytesAdded: 0,
|
||||
filesAdded: 0,
|
||||
id: '5bfb0907',
|
||||
status: 'PENDING',
|
||||
totalBytes: 0,
|
||||
totalFiles: 0
|
||||
}
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule],
|
||||
providers: [
|
||||
@@ -101,6 +90,13 @@ describe('DownloadZipDialogComponent', () => {
|
||||
});
|
||||
|
||||
it('should call cancelDownload when CANCEL button is clicked', () => {
|
||||
spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
||||
return new Observable((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
spyOn(component, 'cancelDownload');
|
||||
|
||||
@@ -111,12 +107,25 @@ describe('DownloadZipDialogComponent', () => {
|
||||
});
|
||||
|
||||
it('should call createDownload when component is initialize', () => {
|
||||
const createDownloadSpy = spyOn(downloadZipService, 'createDownload').and.returnValue(of(pendingDownloadEntry));
|
||||
const createDownloadSpy = spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
||||
return new Observable((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(createDownloadSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should close dialog when download is completed', () => {
|
||||
spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
||||
return new Observable((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
|
||||
component.download('fakeUrl', 'fileName');
|
||||
spyOn(component, 'cancelDownload');
|
||||
fixture.detectChanges();
|
||||
@@ -124,6 +133,13 @@ describe('DownloadZipDialogComponent', () => {
|
||||
});
|
||||
|
||||
it('should close dialog when download is cancelled', () => {
|
||||
spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
||||
return new Observable((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
component.download('url', 'filename');
|
||||
spyOn(downloadZipService, 'cancelDownload');
|
||||
|
Reference in New Issue
Block a user