55946: Removed unnecessary files and created tests

This commit is contained in:
Kristof De Langhe
2018-10-09 15:32:55 +02:00
parent fb0e1d81e4
commit 7d9afeefea
7 changed files with 73 additions and 8 deletions

View File

@@ -7,7 +7,6 @@ import { Item } from '../../core/shared/item.model';
@Component({ @Component({
selector: 'ds-edit-item-page', selector: 'ds-edit-item-page',
styleUrls: ['./edit-item-page.component.scss'],
templateUrl: './edit-item-page.component.html', templateUrl: './edit-item-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
animations: [ animations: [

View File

@@ -1,27 +1,27 @@
<p class="mt-2">{{'item.edit.tabs.status.description' | translate}}</p> <p class="mt-2">{{'item.edit.tabs.status.description' | translate}}</p>
<div class="row"> <div class="row">
<div *ngFor="let statusKey of statusDataKeys" class="w-100"> <div *ngFor="let statusKey of statusDataKeys" class="w-100">
<div class="col-3 float-left"> <div class="col-3 float-left status-label">
{{'item.edit.tabs.status.labels.' + statusKey | translate}}: {{'item.edit.tabs.status.labels.' + statusKey | translate}}:
</div> </div>
<div class="col-9 float-left"> <div class="col-9 float-left status-data" id="status-{{statusKey}}">
{{statusData[statusKey]}} {{statusData[statusKey]}}
</div> </div>
</div> </div>
<div class="col-3 float-left"> <div class="col-3 float-left status-label">
{{'item.edit.tabs.status.labels.itemPage' | translate}}: {{'item.edit.tabs.status.labels.itemPage' | translate}}:
</div> </div>
<div class="col-9 float-left"> <div class="col-9 float-left status-data" id="status-itemPage">
<a href="{{getItemPage()}}">{{getItemPage()}}</a> <a href="{{getItemPage()}}">{{getItemPage()}}</a>
</div> </div>
<div *ngFor="let actionKey of actionsKeys" class="w-100 pt-3"> <div *ngFor="let actionKey of actionsKeys" class="w-100 pt-3">
<div class="col-3 float-left d-flex h-100"> <div class="col-3 float-left d-flex h-100 action-label">
<span class="justify-content-center align-self-center"> <span class="justify-content-center align-self-center">
{{'item.edit.tabs.status.buttons.' + actionKey + '.label' | translate}} {{'item.edit.tabs.status.buttons.' + actionKey + '.label' | translate}}
</span> </span>
</div> </div>
<div class="col-9 float-left"> <div class="col-9 float-left action-button">
<a class="btn btn-outline-secondary" href="{{actions[actionKey]}}"> <a class="btn btn-outline-secondary" href="{{actions[actionKey]}}">
{{'item.edit.tabs.status.buttons.' + actionKey + '.button' | translate}} {{'item.edit.tabs.status.buttons.' + actionKey + '.button' | translate}}
</a> </a>

View File

@@ -0,0 +1,67 @@
import { ItemStatusComponent } from './item-status.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { CommonModule } from '@angular/common';
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub';
import { HostWindowService } from '../../../shared/host-window.service';
import { RouterTestingModule } from '@angular/router/testing';
import { Router } from '@angular/router';
import { RouterStub } from '../../../shared/testing/router-stub';
import { Item } from '../../../core/shared/item.model';
import { By } from '@angular/platform-browser';
describe('ItemStatusComponent', () => {
let comp: ItemStatusComponent;
let fixture: ComponentFixture<ItemStatusComponent>;
const mockItem = Object.assign(new Item(), {
id: 'fake-id',
handle: 'fake/handle',
lastModified: '2018'
});
const itemPageUrl = `fake-url/${mockItem.id}`;
const routerStub = Object.assign(new RouterStub(), {
url: `${itemPageUrl}/edit`
});
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
declarations: [ItemStatusComponent],
providers: [
{ provide: Router, useValue: routerStub },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ItemStatusComponent);
comp = fixture.componentInstance;
comp.item = mockItem;
fixture.detectChanges();
});
it('should display the item\'s internal id', () => {
const statusId: HTMLElement = fixture.debugElement.query(By.css('.status-data#status-id')).nativeElement;
expect(statusId.textContent).toContain(mockItem.id);
});
it('should display the item\'s handle', () => {
const statusHandle: HTMLElement = fixture.debugElement.query(By.css('.status-data#status-handle')).nativeElement;
expect(statusHandle.textContent).toContain(mockItem.handle);
});
it('should display the item\'s last modified date', () => {
const statusLastModified: HTMLElement = fixture.debugElement.query(By.css('.status-data#status-lastModified')).nativeElement;
expect(statusLastModified.textContent).toContain(mockItem.lastModified);
});
it('should display the item\'s page url', () => {
const statusItemPage: HTMLElement = fixture.debugElement.query(By.css('.status-data#status-itemPage')).nativeElement;
expect(statusItemPage.textContent).toContain(itemPageUrl);
});
});

View File

@@ -5,7 +5,6 @@ import { Router } from '@angular/router';
@Component({ @Component({
selector: 'ds-item-status', selector: 'ds-item-status',
styleUrls: ['./item-status.component.scss'],
templateUrl: './item-status.component.html', templateUrl: './item-status.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
animations: [ animations: [