Encapsulate Test Suites for better readability
parent
d29c16005e
commit
ad73633ae8
|
@ -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,10 +56,10 @@ describe('Blog Entry Isolated Test', () => {
|
|||
// nur durch click-Event auslösen, was jedoch BlogComponent vorraussetzt
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('BlogEntryComp -> BlogComp Dependent Test', () => {
|
||||
describe('BlogEntryComp -> BlogComp Dependent Test', () => {
|
||||
|
||||
it('should remove entry from BlogComponent on "delete" button click', () => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -81,4 +82,8 @@ describe('BlogEntryComp -> BlogComp Dependent Test', () => {
|
|||
expect(blogInstance.entries.length).toBe(oldLength - 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
@ -48,10 +48,10 @@ describe('Blog Component Isolated Test', () => {
|
|||
}
|
||||
}).not.toBe(latestId);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Blog Component Integration Form Test', () => {
|
||||
describe('Template Driven Form Integration Test', () => {
|
||||
|
||||
let fixture;
|
||||
let instance;
|
||||
|
@ -84,4 +84,6 @@ describe('Blog Component Integration Form Test', () => {
|
|||
expect(spy).toHaveBeenCalledWith(testTitle, testImage, testText);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('EditTask Component', () => {
|
|||
});
|
||||
|
||||
|
||||
describe('Template Driven Form API-based Test', ()=>{
|
||||
describe('Template Driven Form API-based Test', () => {
|
||||
|
||||
let fixture;
|
||||
|
||||
|
@ -51,7 +51,7 @@ describe('EditTask Component', () => {
|
|||
fixture.autoDetectChanges(true);
|
||||
});
|
||||
|
||||
it('should validate the title correctly', (done)=> {
|
||||
it('should validate the title correctly', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
form = fixture.componentInstance.form.form;
|
||||
const titleControl = form.get('title');
|
||||
|
@ -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};
|
||||
|
@ -127,7 +127,7 @@ describe('EditTask Component', () => {
|
|||
|
||||
});
|
||||
|
||||
describe('Routing', ()=>{
|
||||
describe('Routing', () => {
|
||||
|
||||
let taskService: TaskService;
|
||||
|
||||
|
|
Loading…
Reference in New Issue