upload-bitstream.component.spec.ts (dspace-angular-dspace-7.0) | : | upload-bitstream.component.spec.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
import { VarDirective } from '../../../shared/utils/var.directive'; | import { VarDirective } from '../../../shared/utils/var.directive'; | |||
import { Bitstream } from '../../../core/shared/bitstream.model'; | import { Bitstream } from '../../../core/shared/bitstream.model'; | |||
import { BundleDataService } from '../../../core/data/bundle-data.service'; | import { BundleDataService } from '../../../core/data/bundle-data.service'; | |||
import { Bundle } from '../../../core/shared/bundle.model'; | import { Bundle } from '../../../core/shared/bundle.model'; | |||
import { RequestService } from '../../../core/data/request.service'; | import { RequestService } from '../../../core/data/request.service'; | |||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } f rom '../../../shared/remote-data.utils'; | import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } f rom '../../../shared/remote-data.utils'; | |||
import { createPaginatedList } from '../../../shared/testing/utils.test'; | import { createPaginatedList } from '../../../shared/testing/utils.test'; | |||
import { RouterStub } from '../../../shared/testing/router.stub'; | import { RouterStub } from '../../../shared/testing/router.stub'; | |||
import { NotificationsServiceStub } from '../../../shared/testing/notifications- service.stub'; | import { NotificationsServiceStub } from '../../../shared/testing/notifications- service.stub'; | |||
import { AuthServiceStub } from '../../../shared/testing/auth-service.stub'; | import { AuthServiceStub } from '../../../shared/testing/auth-service.stub'; | |||
import { getTestScheduler } from 'jasmine-marbles'; | ||||
describe('UploadBistreamComponent', () => { | describe('UploadBistreamComponent', () => { | |||
let comp: UploadBitstreamComponent; | let comp: UploadBitstreamComponent; | |||
let fixture: ComponentFixture<UploadBitstreamComponent>; | let fixture: ComponentFixture<UploadBitstreamComponent>; | |||
const bundle = Object.assign(new Bundle(), { | const bundle = Object.assign(new Bundle(), { | |||
id: 'bundle', | id: 'bundle', | |||
uuid: 'bundle', | uuid: 'bundle', | |||
metadata: { | metadata: { | |||
'dc.title': [ | 'dc.title': [ | |||
skipping to change at line 79 | skipping to change at line 80 | |||
} | } | |||
] | ] | |||
}, | }, | |||
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([bundle])) | bundles: createSuccessfulRemoteDataObject$(createPaginatedList([bundle])) | |||
}); | }); | |||
let routeStub; | let routeStub; | |||
const routerStub = new RouterStub(); | const routerStub = new RouterStub(); | |||
const restEndpoint = 'fake-rest-endpoint'; | const restEndpoint = 'fake-rest-endpoint'; | |||
const mockItemDataService = jasmine.createSpyObj('mockItemDataService', { | const mockItemDataService = jasmine.createSpyObj('mockItemDataService', { | |||
getBitstreamsEndpoint: observableOf(restEndpoint), | getBitstreamsEndpoint: observableOf(restEndpoint), | |||
createBundle: createSuccessfulRemoteDataObject$(createdBundle) | createBundle: createSuccessfulRemoteDataObject$(createdBundle), | |||
getBundles: createSuccessfulRemoteDataObject$([bundle]) | ||||
}); | }); | |||
const bundleService = jasmine.createSpyObj('bundleService', { | const bundleService = jasmine.createSpyObj('bundleService', { | |||
getBitstreamsEndpoint: observableOf(restEndpoint), | getBitstreamsEndpoint: observableOf(restEndpoint), | |||
findById: createSuccessfulRemoteDataObject$(bundle) | findById: createSuccessfulRemoteDataObject$(bundle) | |||
}); | }); | |||
const authToken = 'fake-auth-token'; | const authToken = 'fake-auth-token'; | |||
const authServiceStub = Object.assign(new AuthServiceStub(), { | const authServiceStub = Object.assign(new AuthServiceStub(), { | |||
buildAuthHeader: () => authToken | buildAuthHeader: () => authToken | |||
}); | }); | |||
const notificationsServiceStub = new NotificationsServiceStub(); | const notificationsServiceStub = new NotificationsServiceStub(); | |||
const uploaderComponent = jasmine.createSpyObj('uploaderComponent', ['ngOnInit ', 'ngAfterViewInit']); | const uploaderComponent = jasmine.createSpyObj('uploaderComponent', ['ngOnInit ', 'ngAfterViewInit']); | |||
const requestService = jasmine.createSpyObj('requestService', { | const requestService = jasmine.createSpyObj('requestService', { | |||
removeByHrefSubstring: {} | removeByHrefSubstring: {} | |||
}); | }); | |||
describe('on init', () => { | ||||
beforeEach(waitForAsync(() => { | ||||
createUploadBitstreamTestingModule({ | ||||
bundle: bundle.id | ||||
}); | ||||
})); | ||||
beforeEach(() => { | ||||
loadFixtureAndComp(); | ||||
}); | ||||
it('should initialize the bundles', () => { | ||||
expect(comp.bundlesRD$).toBeDefined(); | ||||
getTestScheduler().expectObservable(comp.bundlesRD$).toBe('(a|)', {a: crea | ||||
teSuccessfulRemoteDataObject([bundle])}); | ||||
}); | ||||
}); | ||||
describe('when a file is uploaded', () => { | describe('when a file is uploaded', () => { | |||
beforeEach(waitForAsync(() => { | beforeEach(waitForAsync(() => { | |||
createUploadBitstreamTestingModule({}); | createUploadBitstreamTestingModule({}); | |||
})); | })); | |||
beforeEach(() => { | beforeEach(() => { | |||
loadFixtureAndComp(); | loadFixtureAndComp(); | |||
}); | }); | |||
describe('and it fails, calling onUploadError', () => { | describe('and it fails, calling onUploadError', () => { | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 19 lines changed or added |