Encapsulate Test Suites for better readability

merge-requests/1/head
Florian Hartwich 2017-04-12 19:37:52 +02:00
parent d29c16005e
commit ad73633ae8
6 changed files with 157 additions and 149 deletions

View File

@ -6,6 +6,7 @@ import {RouterTestingModule} from "@angular/router/testing";
describe('Blog Entry Isolated Test', () => {
describe('Isolated Test', () => {
it('should render DOM correctly according to Input', () => {
// Umgebung initialisieren
TestBed.configureTestingModule({
@ -55,9 +56,9 @@ describe('Blog Entry Isolated Test', () => {
// nur durch click-Event auslösen, was jedoch BlogComponent vorraussetzt
});
});
describe('BlogEntryComp -> BlogComp Dependent Test', () => {
it('should remove entry from BlogComponent on "delete" button click', () => {
@ -82,3 +83,7 @@ describe('BlogEntryComp -> BlogComp Dependent Test', () => {
});
});
});

View File

@ -2,10 +2,10 @@ import {BlogComponent} from './blog.component'
import {TestBed} from "@angular/core/testing";
import {RouterTestingModule} from "@angular/router/testing";
import {BlogEntryComponent} from "./blog-entry/blog-entry.component";
import {BlogEntry} from "./blog-entry/blog-entry";
describe('Blog Component Isolated Test', () => {
describe('Blog Component', () => {
describe('Isolated Class Test', () => {
let blogComponent: BlogComponent;
beforeEach(() => {
@ -20,7 +20,7 @@ describe('Blog Component Isolated Test', () => {
})
});
it('should create new list entry and increment id', () => {
it('should create new list entry and increment id-pointer', () => {
let preCreationId = blogComponent.id;
let entryTitle = "some fancy title";
let entryImage = "https://avatars1.githubusercontent.com/u/3284117";
@ -51,7 +51,7 @@ describe('Blog Component Isolated Test', () => {
});
describe('Blog Component Integration Form Test', () => {
describe('Template Driven Form Integration Test', () => {
let fixture;
let instance;
@ -85,3 +85,5 @@ describe('Blog Component Integration Form Test', () => {
})
});
});

View File

@ -32,6 +32,7 @@ export class LoginService {
return this.results$;
}
// Nur als theoretische Umsetzung - in Realität findet die PW-Validierung serverseitig statt
login(name, password) : boolean {
if (this.getUser(name)) {
let user = this.results$[0];

View File

@ -38,7 +38,7 @@ describe('Login-Service', () => {
})
);
it('should trigger a HTTP-GET and receive Task', (() => {
it('should trigger a HTTP-GET and receive Users', (() => {
mockBackend.connections.subscribe(connection => {
const expectedUrl = 'http://localhost:3000/api/users/';
expect(connection.request.url).toBe(expectedUrl);

View File

@ -13,24 +13,24 @@ export class UserStore {
this.items$.next(this.users);
}
_reduce(tasks: User[], action) {
_reduce(users: User[], action) {
switch (action.type) {
case LOAD:
return [...action.data];
case ADD:
return [...tasks, action.data];
return [...users, action.data];
case EDIT:
return tasks.map(task => {
const editedTask = action.data;
if (task.id !== editedTask.id) {
return task;
return users.map(user => {
const editedUser = action.data;
if (user.id !== editedUser.id) {
return user;
}
return editedTask;
return editedUser;
});
case REMOVE:
return tasks.filter(task => task.id !== action.data.id);
return users.filter(task => task.id !== action.data.id);
default:
return tasks;
return users;
}
}

View File

@ -103,7 +103,7 @@ describe('EditTask Component', () => {
});
});
it('should show error on tag name provided with gt 0 and lt 3', (done) => {
it('should validate assignee email correctly', (done) => {
fixture.whenStable().then(() => {
form = fixture.componentInstance.form.form;
const invalidEmailObject = {invalidEMail: true};