55946: Removal of unnecessary scss files and test fixes

This commit is contained in:
Kristof De Langhe
2018-10-10 13:51:02 +02:00
parent 0b3b5d3965
commit 0cf91fb05e
6 changed files with 27 additions and 51 deletions

View File

@@ -1,7 +1,5 @@
import { CollectionSelectComponent } from './item-select.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
@@ -15,45 +13,25 @@ import { HostWindowService } from '../../host-window.service';
import { HostWindowServiceStub } from '../../testing/host-window-service-stub'; import { HostWindowServiceStub } from '../../testing/host-window-service-stub';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { CollectionSelectComponent } from './collection-select.component';
import { Collection } from '../../../core/shared/collection.model';
describe('ItemSelectComponent', () => { describe('ItemSelectComponent', () => {
let comp: CollectionSelectComponent; let comp: CollectionSelectComponent;
let fixture: ComponentFixture<CollectionSelectComponent>; let fixture: ComponentFixture<CollectionSelectComponent>;
let itemSelectService: ObjectSelectService; let objectSelectService: ObjectSelectService;
const mockItemList = [ const mockCollectionList = [
Object.assign(new Item(), { Object.assign(new Collection(), {
id: 'id1', id: 'id1',
bitstreams: Observable.of({}), name: 'name1'
metadata: [
{
key: 'dc.title',
language: 'en_US',
value: 'This is just a title'
},
{
key: 'dc.type',
language: null,
value: 'Article'
}]
}), }),
Object.assign(new Item(), { Object.assign(new Collection(), {
id: 'id2', id: 'id2',
bitstreams: Observable.of({}), name: 'name2'
metadata: [
{
key: 'dc.title',
language: 'en_US',
value: 'This is just another title'
},
{
key: 'dc.type',
language: null,
value: 'Article'
}]
}) })
]; ];
const mockItems = Observable.of(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), mockItemList))); const mockCollections = Observable.of(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), mockCollectionList)));
const mockPaginationOptions = Object.assign(new PaginationComponentOptions(), { const mockPaginationOptions = Object.assign(new PaginationComponentOptions(), {
id: 'search-page-configuration', id: 'search-page-configuration',
pageSize: 10, pageSize: 10,
@@ -75,22 +53,22 @@ describe('ItemSelectComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(CollectionSelectComponent); fixture = TestBed.createComponent(CollectionSelectComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
comp.itemsRD$ = mockItems; comp.dsoRD$ = mockCollections;
comp.paginationOptions = mockPaginationOptions; comp.paginationOptions = mockPaginationOptions;
fixture.detectChanges(); fixture.detectChanges();
itemSelectService = (comp as any).itemSelectService; objectSelectService = (comp as any).objectSelectService;
}); });
it(`should show a list of ${mockItemList.length} items`, () => { it(`should show a list of ${mockCollectionList.length} collections`, () => {
const tbody: HTMLElement = fixture.debugElement.query(By.css('table#item-select tbody')).nativeElement; const tbody: HTMLElement = fixture.debugElement.query(By.css('table#collection-select tbody')).nativeElement;
expect(tbody.children.length).toBe(mockItemList.length); expect(tbody.children.length).toBe(mockCollectionList.length);
}); });
describe('checkboxes', () => { describe('checkboxes', () => {
let checkbox: HTMLInputElement; let checkbox: HTMLInputElement;
beforeEach(() => { beforeEach(() => {
checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement; checkbox = fixture.debugElement.query(By.css('input.collection-checkbox')).nativeElement;
}); });
it('should initially be unchecked',() => { it('should initially be unchecked',() => {
@@ -103,10 +81,10 @@ describe('ItemSelectComponent', () => {
expect(checkbox.checked).toBeTruthy(); expect(checkbox.checked).toBeTruthy();
}); });
it('should switch the value through item-select-service', () => { it('should switch the value through object-select-service', () => {
spyOn((comp as any).itemSelectService, 'switch').and.callThrough(); spyOn((comp as any).objectSelectService, 'switch').and.callThrough();
checkbox.click(); checkbox.click();
expect((comp as any).itemSelectService.switch).toHaveBeenCalled(); expect((comp as any).objectSelectService.switch).toHaveBeenCalled();
}); });
}); });
@@ -114,11 +92,11 @@ describe('ItemSelectComponent', () => {
let confirmButton: HTMLButtonElement; let confirmButton: HTMLButtonElement;
beforeEach(() => { beforeEach(() => {
confirmButton = fixture.debugElement.query(By.css('button.item-confirm')).nativeElement; confirmButton = fixture.debugElement.query(By.css('button.collection-confirm')).nativeElement;
spyOn(comp.confirm, 'emit').and.callThrough(); spyOn(comp.confirm, 'emit').and.callThrough();
}); });
it('should emit the selected items',() => { it('should emit the selected collections',() => {
confirmButton.click(); confirmButton.click();
expect(comp.confirm.emit).toHaveBeenCalled(); expect(comp.confirm.emit).toHaveBeenCalled();
}); });

View File

@@ -6,7 +6,6 @@ import { ObjectSelectService } from '../object-select.service';
@Component({ @Component({
selector: 'ds-collection-select', selector: 'ds-collection-select',
styleUrls: ['./collection-select.component.scss'],
templateUrl: './collection-select.component.html' templateUrl: './collection-select.component.html'
}) })

View File

@@ -19,7 +19,7 @@ import { By } from '@angular/platform-browser';
describe('ItemSelectComponent', () => { describe('ItemSelectComponent', () => {
let comp: ItemSelectComponent; let comp: ItemSelectComponent;
let fixture: ComponentFixture<ItemSelectComponent>; let fixture: ComponentFixture<ItemSelectComponent>;
let itemSelectService: ObjectSelectService; let objectSelectService: ObjectSelectService;
const mockItemList = [ const mockItemList = [
Object.assign(new Item(), { Object.assign(new Item(), {
@@ -75,10 +75,10 @@ describe('ItemSelectComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ItemSelectComponent); fixture = TestBed.createComponent(ItemSelectComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
comp.itemsRD$ = mockItems; comp.dsoRD$ = mockItems;
comp.paginationOptions = mockPaginationOptions; comp.paginationOptions = mockPaginationOptions;
fixture.detectChanges(); fixture.detectChanges();
itemSelectService = (comp as any).itemSelectService; objectSelectService = (comp as any).objectSelectService;
}); });
it(`should show a list of ${mockItemList.length} items`, () => { it(`should show a list of ${mockItemList.length} items`, () => {
@@ -103,10 +103,10 @@ describe('ItemSelectComponent', () => {
expect(checkbox.checked).toBeTruthy(); expect(checkbox.checked).toBeTruthy();
}); });
it('should switch the value through item-select-service', () => { it('should switch the value through object-select-service', () => {
spyOn((comp as any).itemSelectService, 'switch').and.callThrough(); spyOn((comp as any).objectSelectService, 'switch').and.callThrough();
checkbox.click(); checkbox.click();
expect((comp as any).itemSelectService.switch).toHaveBeenCalled(); expect((comp as any).objectSelectService.switch).toHaveBeenCalled();
}); });
}); });

View File

@@ -11,7 +11,6 @@ import { isNotEmpty } from '../../empty.util';
@Component({ @Component({
selector: 'ds-item-select', selector: 'ds-item-select',
styleUrls: ['./item-select.component.scss'],
templateUrl: './item-select.component.html' templateUrl: './item-select.component.html'
}) })