mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
refactor test, change type in table
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<div>{{ message.ldnService }}</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>{{ message.coarNotifyType }}</div>
|
||||
<div>{{ message.activityStreamType }}</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>{{ message.queueStatusLabel | translate}}</div>
|
||||
|
@@ -24,7 +24,7 @@ export const mockAdminNotifyMessages = [
|
||||
{
|
||||
'type': 'message',
|
||||
'id': 'urn:uuid:5fb3af44-d4f8-4226-9475-2d09c2d8d9e0',
|
||||
'coarNotifyType': 'ReviewAction',
|
||||
'coarNotifyType': 'coar-notify:ReviewAction',
|
||||
'activityStreamType': 'TentativeReject',
|
||||
'inReplyTo': 'urn:uuid:f7289ad5-0955-4c86-834c-fb54a736778b',
|
||||
'object': null,
|
||||
@@ -50,7 +50,7 @@ export const mockAdminNotifyMessages = [
|
||||
{
|
||||
'type': 'message',
|
||||
'id': 'urn:uuid:544c8777-e826-4810-a625-3e394cc3660d',
|
||||
'coarNotifyType': 'IngestAction',
|
||||
'coarNotifyType': 'coar-notify:IngestAction',
|
||||
'activityStreamType': 'Announce',
|
||||
'inReplyTo': 'urn:uuid:b2ad72d6-6ea9-464f-b385-29a78417f6b8',
|
||||
'object': null,
|
||||
@@ -78,7 +78,6 @@ export const mockAdminNotifyMessages = [
|
||||
export const mockUnformattedAdminNotifyMessages = mockAdminNotifyMessages.map(
|
||||
message => ({
|
||||
...message,
|
||||
coarNotifyType: 'coar:' + message.coarNotifyType,
|
||||
queueStatusLabel: Object.keys(QueueStatusMap)[Object.values(QueueStatusMap).indexOf(message.queueStatusLabel as unknown as QueueStatusMap)]
|
||||
})
|
||||
) as unknown as AdminNotifyMessage[];
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { cold, getTestScheduler } from 'jasmine-marbles';
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { AdminNotifyMessagesService } from './admin-notify-messages.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
|
||||
@@ -20,9 +19,9 @@ import {
|
||||
} from '../admin-notify-search-result/admin-notify-search-result.component.spec';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { deepClone } from 'fast-json-patch';
|
||||
import { AdminNotifyMessage } from "../models/admin-notify-message.model";
|
||||
|
||||
describe('AdminNotifyMessagesService test', () => {
|
||||
let scheduler: TestScheduler;
|
||||
let service: AdminNotifyMessagesService;
|
||||
let requestService: RequestService;
|
||||
let rdbService: RemoteDataBuildService;
|
||||
@@ -32,8 +31,9 @@ describe('AdminNotifyMessagesService test', () => {
|
||||
let ldnServicesService: LdnServicesService;
|
||||
let itemDataService: ItemDataService;
|
||||
let responseCacheEntry: RequestEntry;
|
||||
let mockMessages : AdminNotifyMessage[];
|
||||
|
||||
const endpointURL = `https://rest.api/rest/api/messages`;
|
||||
const endpointURL = `https://rest.api/rest/api/ldn/messages`;
|
||||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
||||
const remoteDataMocks = {
|
||||
Success: new RemoteData(null, null, null, RequestEntryState.Success, null, null, 200),
|
||||
@@ -54,8 +54,7 @@ describe('AdminNotifyMessagesService test', () => {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
mockMessages = deepClone(mockUnformattedAdminNotifyMessages)
|
||||
objectCache = {} as ObjectCacheService;
|
||||
notificationsService = {} as NotificationsService;
|
||||
responseCacheEntry = new RequestEntry();
|
||||
@@ -78,7 +77,7 @@ describe('AdminNotifyMessagesService test', () => {
|
||||
rdbService = jasmine.createSpyObj('rdbService', {
|
||||
buildSingle: createSuccessfulRemoteDataObject$({}, 500),
|
||||
buildList: cold('a', { a: remoteDataMocks.Success }),
|
||||
buildFromRequestUUID: createSuccessfulRemoteDataObject$(deepClone(mockUnformattedAdminNotifyMessages))
|
||||
buildFromRequestUUID: createSuccessfulRemoteDataObject$(mockMessages)
|
||||
});
|
||||
|
||||
ldnServicesService = jasmine.createSpyObj('ldnServicesService', {
|
||||
@@ -89,9 +88,7 @@ describe('AdminNotifyMessagesService test', () => {
|
||||
findById: createSuccessfulRemoteDataObject$({name: testRelatedItemName}),
|
||||
});
|
||||
|
||||
|
||||
service = initTestService();
|
||||
|
||||
});
|
||||
|
||||
describe('Admin Notify service', () => {
|
||||
@@ -100,12 +97,12 @@ describe('AdminNotifyMessagesService test', () => {
|
||||
});
|
||||
|
||||
it('should format message labels', () => {
|
||||
const formattedMessage = service.formatMessageLabels(deepClone(mockUnformattedAdminNotifyMessages[0]));
|
||||
const formattedMessage = service.formatMessageLabels(mockMessages[0]);
|
||||
expect(formattedMessage).toEqual(mockAdminNotifyMessages[0]);
|
||||
});
|
||||
|
||||
it('should get details for messages', (done) => {
|
||||
service.getDetailedMessages(deepClone(mockUnformattedAdminNotifyMessages)).pipe(take(1)).subscribe((detailedMessages) => {
|
||||
service.getDetailedMessages(mockMessages).pipe(take(1)).subscribe((detailedMessages) => {
|
||||
expect(detailedMessages[0].ldnService).toEqual(testLdnServiceName);
|
||||
expect(detailedMessages[0].relatedItem).toEqual(testRelatedItemName);
|
||||
done();
|
||||
@@ -113,11 +110,10 @@ describe('AdminNotifyMessagesService test', () => {
|
||||
});
|
||||
|
||||
it('should reprocess message', (done) => {
|
||||
const messages = deepClone(mockUnformattedAdminNotifyMessages);
|
||||
const behaviorSubject = new BehaviorSubject(messages);
|
||||
service.reprocessMessage(messages[0], behaviorSubject).pipe(take(1)).subscribe((reprocessedMessages) => {
|
||||
const behaviorSubject = new BehaviorSubject(mockMessages);
|
||||
service.reprocessMessage(mockMessages[0], behaviorSubject).pipe(take(1)).subscribe((reprocessedMessages) => {
|
||||
expect(reprocessedMessages.length).toEqual(2);
|
||||
expect(reprocessedMessages).toEqual(messages);
|
||||
expect(reprocessedMessages).toEqual(mockMessages);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -46,7 +46,6 @@ export class AdminNotifyMessagesService extends IdentifiableDataService<AdminNot
|
||||
* @param message the message to which map the labels
|
||||
*/
|
||||
public formatMessageLabels(message: AdminNotifyMessage): AdminNotifyMessage {
|
||||
message.coarNotifyType = message.coarNotifyType?.split(':')[1];
|
||||
message.queueStatusLabel = QueueStatusMap[message.queueStatusLabel];
|
||||
return message;
|
||||
}
|
||||
|
Reference in New Issue
Block a user