mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-4875] Fixed commenting, service test & compoent from issue 1472
This commit is contained in:
104
src/app/core/feedback/feedback-data.service.spec.ts
Normal file
104
src/app/core/feedback/feedback-data.service.spec.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { FeedbackDataService } from './feedback-data.service';
|
||||
import { HALLink } from '../shared/hal-link.model';
|
||||
import { Item } from '../shared/item.model';
|
||||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { DSOChangeAnalyzer } from 'src/app/core/data/dso-change-analyzer.service';
|
||||
import { Feedback } from './models/feedback.model';
|
||||
|
||||
describe('FeedbackDataService', () => {
|
||||
let service: FeedbackDataService;
|
||||
let requestService;
|
||||
let halService;
|
||||
let rdbService;
|
||||
let notificationsService;
|
||||
let http;
|
||||
let comparator;
|
||||
let objectCache;
|
||||
let store;
|
||||
let item;
|
||||
let bundleLink;
|
||||
let bundleHALLink;
|
||||
|
||||
const feedbackPayload = Object.assign(new Feedback(), {
|
||||
email: 'test@email.com',
|
||||
message: 'message',
|
||||
page: '/home'
|
||||
});
|
||||
|
||||
const linkName = 'feedbacks';
|
||||
|
||||
|
||||
function initTestService(): FeedbackDataService {
|
||||
bundleLink = '/items/0fdc0cd7-ff8c-433d-b33c-9b56108abc07/bundles';
|
||||
bundleHALLink = new HALLink();
|
||||
bundleHALLink.href = bundleLink;
|
||||
item = new Item();
|
||||
item._links = {
|
||||
bundles: bundleHALLink
|
||||
};
|
||||
requestService = getMockRequestService();
|
||||
halService = new HALEndpointServiceStub('url') as any;
|
||||
rdbService = {} as RemoteDataBuildService;
|
||||
notificationsService = {} as NotificationsService;
|
||||
http = {} as HttpClient;
|
||||
comparator = new DSOChangeAnalyzer() as any;
|
||||
objectCache = {
|
||||
|
||||
addPatch: () => {
|
||||
/* empty */
|
||||
},
|
||||
getObjectBySelfLink: () => {
|
||||
/* empty */
|
||||
}
|
||||
} as any;
|
||||
store = {} as Store<CoreState>;
|
||||
return new FeedbackDataService(
|
||||
requestService,
|
||||
rdbService,
|
||||
store,
|
||||
objectCache,
|
||||
halService,
|
||||
notificationsService,
|
||||
http,
|
||||
comparator,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
beforeEach(() => {
|
||||
service = initTestService();
|
||||
});
|
||||
|
||||
|
||||
describe('getFeedback', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getFeedback');
|
||||
service.getFeedback('3');
|
||||
});
|
||||
|
||||
it('should call getFeedback with the feedback link', () => {
|
||||
expect(service.getFeedback).toHaveBeenCalledWith('3');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('createFeedback', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'postToEndpoint');
|
||||
service.createFeedback(feedbackPayload);
|
||||
});
|
||||
|
||||
it('should call postToEndpoint with the linkName and payload', () => {
|
||||
expect(service.postToEndpoint).toHaveBeenCalledWith(linkName, feedbackPayload);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -21,7 +21,7 @@ import { PostRequest } from 'src/app/core/data/request.models';
|
||||
import { RemoteData } from 'src/app/core/data/remote-data';
|
||||
|
||||
/**
|
||||
* Service for checking and managing the status of the current end user agreement
|
||||
* Service for checking and managing the feedback
|
||||
*/
|
||||
@Injectable()
|
||||
@dataService(FEEDBACK)
|
||||
@@ -37,7 +37,7 @@ export class FeedbackDataService extends DataService<Feedback> {
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DSOChangeAnalyzer<Feedback>,
|
||||
protected authService: AuthService, ) {
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<fieldset class="col p-0">
|
||||
<div class="row">
|
||||
<div class="control-group col-sm-12">
|
||||
<label class="control-label" for="email">Your Email: </label>
|
||||
<label class="control-label" for="email">{{ 'info.feedback.email-label' | translate }} </label>
|
||||
<input id="email" class="form-control" name="email" type="text" value="" formControlName="email" autofocus="autofocus" title="{{ 'info.feedback.email_help' | translate }}">
|
||||
<p class="help-block">{{ 'info.feedback.email_help' | translate }}</p>
|
||||
</div>
|
@@ -1,7 +1,7 @@
|
||||
import { EPersonMock } from './../../../shared/testing/eperson.mock';
|
||||
import { FeedbackDataService } from './../../../core/feedback/feedback-data.service';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { FeedbackContentComponent } from './feedback-content.component';
|
||||
import { FeedbackFormComponent } from './feedback-form.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NO_ERRORS_SCHEMA, DebugElement } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
@@ -16,9 +16,9 @@ import { of } from 'rxjs/internal/observable/of';
|
||||
import { Feedback } from '../../../core/feedback/models/feedback.model';
|
||||
|
||||
|
||||
describe('FeedbackContentComponent', () => {
|
||||
let component: FeedbackContentComponent;
|
||||
let fixture: ComponentFixture<FeedbackContentComponent>;
|
||||
describe('FeedbackFormComponent', () => {
|
||||
let component: FeedbackFormComponent;
|
||||
let fixture: ComponentFixture<FeedbackFormComponent>;
|
||||
let de: DebugElement;
|
||||
const notificationService = new NotificationsServiceStub();
|
||||
const feedbackDataServiceStub = jasmine.createSpyObj('feedbackDataService', {
|
||||
@@ -33,7 +33,7 @@ describe('FeedbackContentComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
declarations: [FeedbackContentComponent],
|
||||
declarations: [FeedbackFormComponent],
|
||||
providers: [
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
{ provide: FormBuilder, useValue: new FormBuilder() },
|
||||
@@ -46,7 +46,7 @@ describe('FeedbackContentComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FeedbackContentComponent);
|
||||
fixture = TestBed.createComponent(FeedbackFormComponent);
|
||||
component = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
fixture.detectChanges();
|
@@ -13,14 +13,14 @@ import { AuthService } from 'src/app/core/auth/auth.service';
|
||||
import { EPerson } from '../../../core/eperson/models/eperson.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-feedback-content',
|
||||
templateUrl: './feedback-content.component.html',
|
||||
styleUrls: ['./feedback-content.component.scss']
|
||||
selector: 'ds-feedback-form',
|
||||
templateUrl: './feedback-form.component.html',
|
||||
styleUrls: ['./feedback-form.component.scss']
|
||||
})
|
||||
/**
|
||||
* Component displaying the contents of the Feedback Statement
|
||||
*/
|
||||
export class FeedbackContentComponent implements OnInit {
|
||||
export class FeedbackFormComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* Form builder created used from the feedback from
|
@@ -1,3 +1,3 @@
|
||||
<div class="container">
|
||||
<ds-feedback-content></ds-feedback-content>
|
||||
<ds-feedback-form></ds-feedback-form>
|
||||
</div>
|
@@ -9,7 +9,7 @@ import { PrivacyContentComponent } from './privacy/privacy-content/privacy-conte
|
||||
import { ThemedEndUserAgreementComponent } from './end-user-agreement/themed-end-user-agreement.component';
|
||||
import { ThemedPrivacyComponent } from './privacy/themed-privacy.component';
|
||||
import { FeedbackComponent } from './feedback/feedback.component';
|
||||
import { FeedbackContentComponent } from './feedback/feedback-content/feedback-content.component';
|
||||
import { FeedbackFormComponent } from './feedback/feedback-form/feedback-form.component';
|
||||
import { ThemedFeedbackComponent } from './feedback/themed-feedback.component';
|
||||
import { FeedbackGuard } from '../core/feedback/feedback.guard';
|
||||
|
||||
@@ -22,7 +22,7 @@ const DECLARATIONS = [
|
||||
PrivacyContentComponent,
|
||||
ThemedPrivacyComponent,
|
||||
FeedbackComponent,
|
||||
FeedbackContentComponent,
|
||||
FeedbackFormComponent,
|
||||
ThemedFeedbackComponent
|
||||
];
|
||||
|
||||
|
@@ -1583,6 +1583,8 @@
|
||||
"info.feedback.send": "Send Feedback",
|
||||
|
||||
"info.feedback.comments": "Comments",
|
||||
|
||||
"info.feedback.email-label": "Your Email",
|
||||
|
||||
"info.feedback.create.success" : "Feedback Sent Successfully!",
|
||||
|
||||
|
Reference in New Issue
Block a user