mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00

# Conflicts: # src/app/access-control/epeople-registry/epeople-registry.component.html # src/app/access-control/epeople-registry/epeople-registry.component.ts # src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html # src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts # src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts # src/app/access-control/group-registry/group-form/group-form.component.html # src/app/access-control/group-registry/group-form/group-form.component.ts # src/app/access-control/group-registry/group-form/members-list/members-list.component.html # src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts # src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.ts # src/app/admin/admin-registries/metadata-schema/metadata-schema.component.ts # src/app/browse-by/browse-by.module.ts # src/app/community-list-page/community-list/community-list.component.spec.ts # src/app/core/core.module.ts # src/app/core/data/root-data.service.ts # src/app/core/eperson/eperson-data.service.ts # src/app/core/eperson/group-data.service.ts # src/app/curation-form/curation-form.component.ts # src/app/header/header.component.spec.ts # src/app/header/header.component.ts # src/app/health-page/health-page.component.ts # src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.html # src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.spec.ts # src/app/item-page/edit-item-page/item-status/item-status.component.ts # src/app/process-page/form/process-parameters/parameter-select/parameter-select.component.spec.ts # src/app/process-page/form/process-parameters/parameter-value-input/boolean-value-input/boolean-value-input.component.spec.ts # src/app/register-email-form/register-email-form.module.ts # src/app/register-email-form/themed-registry-email-form.component.ts # src/app/shared/auth-nav-menu/auth-nav-menu.component.html # src/app/shared/auth-nav-menu/user-menu/themed-user-menu.component.ts # src/app/shared/browse-by/shared-browse-by.module.ts # src/app/shared/browse-by/themed-browse-by.component.ts # src/app/shared/dso-page/dso-edit-menu/dso-edit-expandable-menu-section/dso-edit-menu-expandable-section.component.ts # src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.ts # src/app/shared/file-download-link/file-download-link.component.spec.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.ts # src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.html # src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.ts # src/app/shared/lang-switch/lang-switch.component.ts # src/app/shared/lang-switch/themed-lang-switch.component.ts # src/app/shared/log-in/log-in.component.ts # src/app/shared/log-in/themed-log-in.component.ts # src/app/shared/menu/menu.component.spec.ts # src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts # src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.spec.ts # src/app/shared/search/search-filters/search-filter/search-filter.component.html # src/app/shared/search/search-labels/search-label/search-label.component.html # src/app/submission/import-external/submission-import-external.component.ts # src/app/subscriptions-page/subscriptions-page.component.ts # src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-select-reviewer/reviewers-list/reviewers-list.component.spec.ts # src/themes/custom/app/entity-groups/research-entities/item-pages/person/person.component.ts # src/themes/custom/app/register-email-form/register-email-form.component.ts # src/themes/custom/app/shared/auth-nav-menu/user-menu/user-menu.component.ts # src/themes/custom/app/shared/browse-by/browse-by.component.ts # src/themes/custom/app/shared/lang-switch/lang-switch.component.ts # src/themes/custom/app/shared/log-in/log-in.component.ts # src/themes/custom/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.ts
96 lines
3.7 KiB
TypeScript
96 lines
3.7 KiB
TypeScript
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
import { Item } from '../../../core/shared/item.model';
|
|
import { RouterStub } from '../../../shared/testing/router.stub';
|
|
import { of as observableOf } from 'rxjs';
|
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
|
import { CommonModule } from '@angular/common';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { RouterTestingModule } from '@angular/router/testing';
|
|
import { TranslateModule } from '@ngx-translate/core';
|
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { ItemDataService } from '../../../core/data/item-data.service';
|
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
import { By } from '@angular/platform-browser';
|
|
import { ItemPublicComponent } from './item-public.component';
|
|
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
|
|
|
let comp: ItemPublicComponent;
|
|
let fixture: ComponentFixture<ItemPublicComponent>;
|
|
|
|
let mockItem;
|
|
let itemPageUrl;
|
|
let routerStub;
|
|
let mockItemDataService: ItemDataService;
|
|
let routeStub;
|
|
let notificationsServiceStub;
|
|
|
|
describe('ItemPublicComponent', () => {
|
|
beforeEach(waitForAsync(() => {
|
|
|
|
mockItem = Object.assign(new Item(), {
|
|
id: 'fake-id',
|
|
handle: 'fake/handle',
|
|
lastModified: '2018',
|
|
isWithdrawn: true
|
|
});
|
|
|
|
itemPageUrl = `fake-url/${mockItem.id}`;
|
|
routerStub = Object.assign(new RouterStub(), {
|
|
url: `${itemPageUrl}/edit`
|
|
});
|
|
|
|
mockItemDataService = jasmine.createSpyObj('mockItemDataService', {
|
|
setDiscoverable: createSuccessfulRemoteDataObject$(mockItem)
|
|
});
|
|
|
|
routeStub = {
|
|
data: observableOf({
|
|
dso: createSuccessfulRemoteDataObject(mockItem)
|
|
})
|
|
};
|
|
|
|
notificationsServiceStub = new NotificationsServiceStub();
|
|
|
|
TestBed.configureTestingModule({
|
|
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, ItemPublicComponent],
|
|
providers: [
|
|
{ provide: ActivatedRoute, useValue: routeStub },
|
|
{ provide: Router, useValue: routerStub },
|
|
{ provide: ItemDataService, useValue: mockItemDataService },
|
|
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
|
], schemas: [
|
|
CUSTOM_ELEMENTS_SCHEMA
|
|
]
|
|
}).compileComponents();
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(ItemPublicComponent);
|
|
comp = fixture.componentInstance;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should render a page with messages based on the \'public\' messageKey', () => {
|
|
const header = fixture.debugElement.query(By.css('h1')).nativeElement;
|
|
expect(header.innerHTML).toContain('item.edit.public.header');
|
|
const description = fixture.debugElement.query(By.css('p')).nativeElement;
|
|
expect(description.innerHTML).toContain('item.edit.public.description');
|
|
const confirmButton = fixture.debugElement.query(By.css('button.perform-action')).nativeElement;
|
|
expect(confirmButton.innerHTML).toContain('item.edit.public.confirm');
|
|
const cancelButton = fixture.debugElement.query(By.css('button.cancel')).nativeElement;
|
|
expect(cancelButton.innerHTML).toContain('item.edit.public.cancel');
|
|
});
|
|
|
|
describe('performAction', () => {
|
|
it('should call setDiscoverable function from the ItemDataService', () => {
|
|
spyOn(comp, 'processRestResponse');
|
|
comp.performAction();
|
|
|
|
expect(mockItemDataService.setDiscoverable).toHaveBeenCalledWith(mockItem, true);
|
|
expect(comp.processRestResponse).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|