"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/shared/search-form/search-form.component.spec.ts" between
dspace-angular-dspace-7.0.tar.gz and dspace-angular-dspace-7.1.tar.gz

About: dspace-angular is the Angular-based frontend of DSpace, a digital repository system to capture, store, index, preserve and redistribute an organization’s research material in digital formats.

search-form.component.spec.ts  (dspace-angular-dspace-7.0):search-form.component.spec.ts  (dspace-angular-dspace-7.1)
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angul ar/core/testing'; import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angul ar/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core'; import { DebugElement } from '@angular/core';
import { SearchFormComponent } from './search-form.component'; import { SearchFormComponent } from './search-form.component';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { Community } from '../../core/shared/community.model'; import { Community } from '../../core/shared/community.model';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { SearchService } from '../../core/shared/search/search.service'; import { SearchService } from '../../core/shared/search/search.service';
import { PaginationComponentOptions } from '../pagination/pagination-component-o
ptions.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
.model';
import { FindListOptions } from '../../core/data/request.models';
import { of as observableOf } from 'rxjs';
import { PaginationService } from '../../core/pagination/pagination.service'; import { PaginationService } from '../../core/pagination/pagination.service';
import { SearchConfigurationService } from '../../core/shared/search/search-conf iguration.service'; import { SearchConfigurationService } from '../../core/shared/search/search-conf iguration.service';
import { PaginationServiceStub } from '../testing/pagination-service.stub'; import { PaginationServiceStub } from '../testing/pagination-service.stub';
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv
ice';
import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
describe('SearchFormComponent', () => { describe('SearchFormComponent', () => {
let comp: SearchFormComponent; let comp: SearchFormComponent;
let fixture: ComponentFixture<SearchFormComponent>; let fixture: ComponentFixture<SearchFormComponent>;
let de: DebugElement; let de: DebugElement;
let el: HTMLElement; let el: HTMLElement;
const paginationService = new PaginationServiceStub(); const paginationService = new PaginationServiceStub();
const searchConfigService = {paginationID: 'test-id'}; const searchConfigService = {paginationID: 'test-id'};
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [FormsModule, RouterTestingModule, TranslateModule.forRoot()], imports: [FormsModule, RouterTestingModule, TranslateModule.forRoot()],
providers: [ providers: [
{ {
provide: SearchService, provide: SearchService,
useValue: {} useValue: {}
}, },
{ provide: PaginationService, useValue: paginationService }, { provide: PaginationService, useValue: paginationService },
{ provide: SearchConfigurationService, useValue: searchConfigService } { provide: SearchConfigurationService, useValue: searchConfigService },
{ provide: DSpaceObjectDataService, useValue: { findById: () => createSu
ccessfulRemoteDataObject$(undefined)} }
], ],
declarations: [SearchFormComponent] declarations: [SearchFormComponent]
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(SearchFormComponent); fixture = TestBed.createComponent(SearchFormComponent);
comp = fixture.componentInstance; // SearchFormComponent test instance comp = fixture.componentInstance; // SearchFormComponent test instance
de = fixture.debugElement.query(By.css('form')); de = fixture.debugElement.query(By.css('form'));
el = de.nativeElement; el = de.nativeElement;
}); });
it('should display scopes when available with default and all scopes', () => {
comp.scopes = objects;
fixture.detectChanges();
const select: HTMLElement = de.query(By.css('select')).nativeElement;
expect(select).toBeDefined();
const options: HTMLCollection = select.children;
const defOption: Element = options.item(0);
expect(defOption.getAttribute('value')).toBe('');
let index = 1;
objects.forEach((object) => {
expect(options.item(index).textContent).toBe(object.name);
expect(options.item(index).getAttribute('value')).toBe(object.uuid);
index++;
});
});
it('should not display scopes when empty', () => { it('should not display scopes when empty', () => {
fixture.detectChanges(); fixture.detectChanges();
const select = de.query(By.css('select')); const select = de.query(By.css('select'));
expect(select).toBeNull(); expect(select).toBeNull();
}); });
it('should display set query value in input field', fakeAsync(() => { it('should display set query value in input field', fakeAsync(() => {
const testString = 'This is a test query'; const testString = 'This is a test query';
comp.query = testString; comp.query = testString;
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
const queryInput = de.query(By.css('input')).nativeElement; const queryInput = de.query(By.css('input')).nativeElement;
expect(queryInput.value).toBe(testString); expect(queryInput.value).toBe(testString);
})); }));
it('should select correct scope option in scope select', fakeAsync(() => { it('should select correct scope option in scope select', fakeAsync(() => {
comp.scopes = objects;
fixture.detectChanges();
fixture.detectChanges();
comp.showScopeSelector = true;
const testCommunity = objects[1]; const testCommunity = objects[1];
comp.scope = testCommunity.id; comp.selectedScope.next(testCommunity);
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
const scopeSelect = de.query(By.css('select')).nativeElement; const scopeSelect = de.query(By.css('.scope-button')).nativeElement;
expect(scopeSelect.value).toBe(testCommunity.id); expect(scopeSelect.textContent).toBe(testCommunity.name);
})); }));
// it('should call updateSearch when clicking the submit button with correct p arameters', fakeAsync(() => { // it('should call updateSearch when clicking the submit button with correct p arameters', fakeAsync(() => {
// comp.query = 'Test String' // comp.query = 'Test String'
// fixture.detectChanges(); // fixture.detectChanges();
// spyOn(comp, 'updateSearch').and.callThrough(); // spyOn(comp, 'updateSearch').and.callThrough();
// fixture.detectChanges(); // fixture.detectChanges();
// //
// const submit = de.query(By.css('button.search-button')).nativeElement; // const submit = de.query(By.css('button.search-button')).nativeElement;
// const scope = '123456'; // const scope = '123456';
// const query = 'test'; // const query = 'test';
skipping to change at line 121 skipping to change at line 102
// tick(); // tick();
// select.value = scope; // select.value = scope;
// input.value = query; // input.value = query;
// //
// fixture.detectChanges(); // fixture.detectChanges();
// //
// submit.click(); // submit.click();
// //
// expect(comp.updateSearch).toHaveBeenCalledWith({ scope: scope, query: que ry }); // expect(comp.updateSearch).toHaveBeenCalledWith({ scope: scope, query: que ry });
// })); // }));
}); });
export const objects: DSpaceObject[] = [ export const objects: DSpaceObject[] = [
Object.assign(new Community(), { Object.assign(new Community(), {
logo: { logo: {
self: { self: {
_isScalar: true, _isScalar: true,
value: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstrea ms/10b636d0-7890-4968-bcd6-0d83bf4e2b42', value: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstrea ms/10b636d0-7890-4968-bcd6-0d83bf4e2b42',
scheduler: null scheduler: null
} }
}, },
 End of changes. 10 change blocks. 
31 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)