Skip to content

Commit 9d2fed4

Browse files
committed
101289: Fixed test issues
1 parent a936878 commit 9d2fed4

4 files changed

Lines changed: 37 additions & 18 deletions

File tree

src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
612612
bundle$ = completedBundleRd$.pipe(
613613
map((bundleRd: RemoteData<Bundle>) => {
614614
if (bundleRd.hasSucceeded) {
615-
return bundleRd.payload
615+
return bundleRd.payload;
616616
} else {
617617
return this.bundle;
618618
}

src/app/core/data/primary-bitstream.service.spec.ts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Bundle } from '../shared/bundle.model';
1616
import { getTestScheduler } from 'jasmine-marbles';
1717
import { of as observableOf } from 'rxjs';
1818

19-
fdescribe('PrimaryBitstreamService', () => {
19+
describe('PrimaryBitstreamService', () => {
2020
let service: PrimaryBitstreamService;
2121
let objectCache: ObjectCacheService;
2222
let requestService: RequestService;
@@ -57,7 +57,7 @@ fdescribe('PrimaryBitstreamService', () => {
5757

5858
describe('getHttpOptions', () => {
5959
it('should return a HttpOptions object with text/url-list Context-Type header', () => {
60-
const result = (service as any).getHttpOptions()
60+
const result = (service as any).getHttpOptions();
6161
expect(result.headers.get('Content-Type')).toEqual('text/uri-list');
6262
});
6363
});
@@ -118,40 +118,63 @@ fdescribe('PrimaryBitstreamService', () => {
118118
});
119119
});
120120
describe('delete', () => {
121+
const testBundle = Object.assign(new Bundle(), {
122+
_links: {
123+
self: {
124+
href: 'test-href'
125+
},
126+
primaryBitstream: {
127+
href: 'test-primaryBitstream-href'
128+
}
129+
}
130+
});
131+
121132
describe('when the delete request succeeds', () => {
122133
const testResult = createSuccessfulRemoteDataObject(new Bundle());
123-
const bundleServiceResult = createSuccessfulRemoteDataObject(bundle);
134+
const bundleServiceResult = createSuccessfulRemoteDataObject(testBundle);
124135

125136
beforeEach(() => {
126137
spyOn((service as any), 'createAndSendRequest').and.returnValue(observableOf(testResult));
127138
(bundleDataService.findByHref as jasmine.Spy<any>).and.returnValue(observableOf(bundleServiceResult));
128139
});
129140

130141
it('should delegate the call to createAndSendRequest', () => {
131-
const result = service.delete(bundle);
132-
getTestScheduler().expectObservable(result).toBe('(a|)', { a: testResult });
142+
const result = service.delete(testBundle);
143+
getTestScheduler().expectObservable(result).toBe('(a|)', { a: bundleServiceResult });
144+
145+
result.subscribe();
146+
147+
expect(bundleDataService.findByHref).toHaveBeenCalledWith(testBundle.self, false);
133148

134149
expect((service as any).createAndSendRequest).toHaveBeenCalledWith(
135150
DeleteRequest,
136-
bundle._links.primaryBitstream.href,
151+
testBundle._links.primaryBitstream.href,
137152
);
138153
});
139154
});
140155
describe('when the delete request fails', () => {
141156
const testResult = createFailedRemoteDataObject();
157+
const bundleServiceResult = createSuccessfulRemoteDataObject(testBundle);
142158

143159
beforeEach(() => {
144160
spyOn((service as any), 'createAndSendRequest').and.returnValue(observableOf(testResult));
161+
(bundleDataService.findByHref as jasmine.Spy<any>).and.returnValue(observableOf(bundleServiceResult));
145162
});
146163

147-
it('should delegate the call to createAndSendRequest and retrieve the bundle from the rdbService', () => {
148-
const result = service.delete(bundle);
149-
getTestScheduler().expectObservable(result).toBe('(a|)', { a: bundle });
150-
164+
it('should delegate the call to createAndSendRequest and request the bundle from the bundleDataService', () => {
165+
const result = service.delete(testBundle);
166+
result.subscribe();
151167
expect((service as any).createAndSendRequest).toHaveBeenCalledWith(
152168
DeleteRequest,
153-
bundle._links.primaryBitstream.href,
169+
testBundle._links.primaryBitstream.href,
154170
);
171+
expect(bundleDataService.findByHref).toHaveBeenCalledWith(testBundle.self, true);
172+
173+
});
174+
175+
it('should delegate the call to createAndSendRequest and', () => {
176+
const result = service.delete(bundle);
177+
getTestScheduler().expectObservable(result).toBe('(a|)', { a: bundleServiceResult });
155178
});
156179
});
157180
});

src/app/core/data/primary-bitstream.service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,7 @@ export class PrimaryBitstreamService {
122122
).pipe(
123123
getAllCompletedRemoteData(),
124124
switchMap((rd: RemoteData<NoContent>) => {
125-
if (rd.hasSucceeded) {
126-
return this.bundleDataService.findByHref(bundle.self, false);
127-
} else {
128-
return this.rdbService.buildSingle<Bundle>(bundle.self);
129-
}
125+
return this.bundleDataService.findByHref(bundle.self, rd.hasFailed);
130126
})
131127
);
132128
}

src/app/core/shared/bundle.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
1+
import { deserialize, inheritSerialization } from 'cerialize';
22

33
import { Observable } from 'rxjs';
44

0 commit comments

Comments
 (0)