Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
create test
  • Loading branch information
macrisguncay committed Mar 16, 2020
commit 69154932b69c1373a8abb491ed5c3f497f3e7421
7 changes: 0 additions & 7 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,4 @@ describe('AppComponent', () => {
const app = fixture.componentInstance;
expect(app.title).toEqual('time-tracker');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('time-tracker app is running!');
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ProjectManagementComponent } from './project-management.component';
import { Project } from '../../../interfaces/project';

describe('ProjectManagementComponent', () => {
let component: ProjectManagementComponent;
let fixture: ComponentFixture<ProjectManagementComponent>;
const projects: Project[] = [{
id: 1,
name: 'app 1',
details: 'It is a good app',
status: 'inactive',
completed: true
},
{
id: 2,
name: 'app 2',
details: 'It is a good app',
status: 'inactive',
completed: false
},
{
id: 3,
name: 'app 3',
details: 'It is a good app',
status: 'active',
completed: true
}
];

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand All @@ -17,9 +40,61 @@ describe('ProjectManagementComponent', () => {
fixture = TestBed.createComponent(ProjectManagementComponent);
component = fixture.componentInstance;
fixture.detectChanges();
component.projects = projects;
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should add a project #updateProject', () => {
const project = {
name: 'app 4',
details: 'It is a good app',
status: 'inactive',
completed: true
};

component.editedProjectId = null;
component.updateProject(project);
expect(component.projects.length).toEqual(4);
});

it('should edit a project #updateProject', () => {
const project = {
id: 1,
name: 'app test',
details: 'It is a excelent app',
status: 'inactive',
completed: true
};

component.editedProjectId = 1;
component.updateProject(project);
expect(component.projects.length).toEqual(3);
expect(component.projects[0].name).toBe('app test');
expect(component.projects[0].details).toBe('It is a excelent app');
expect(component.projects[0].status).toBe('inactive');
expect(component.projects[0].completed).toBe(true);
});

it('should filter the project to edit #editProject', () => {
const editProjectId = 2;
component.editProject(editProjectId);
expect(component.project.name).toBe('app 2');
});

it('should clean the project #cancelForm', () => {
const project = {
id: 1,
name: 'app 1',
details: 'It is a good app',
status: 'inactive',
completed: true
};

component.project = project;
component.cancelForm();
expect(component.project).toBe(null);
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CreateProjectComponent } from './create-project.component';
import { Validators, FormBuilder } from '@angular/forms';

describe('CreateProjectComponent', () => {
let component: CreateProjectComponent;
let fixture: ComponentFixture<CreateProjectComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateProjectComponent ]
declarations: [ CreateProjectComponent ],
providers: [
FormBuilder
],
})
.compileComponents();
}));
Expand Down