Skip to content
Prev Previous commit
Next Next commit
#3 find project
  • Loading branch information
daros10 committed Mar 27, 2020
commit e2ac439aea87957400123c2d6014faf01152bc7a
3 changes: 1 addition & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { EmptyStateComponent } from './components/shared/empty-state/empty-state
import { GroupByDatePipe } from './components/shared/pipes/group-by-date/group-by-date.pipe';
import { SearchProjectComponent } from './components/shared/search-project/search-project.component';
import { FilterProjectPipe } from './components/shared/pipes/filter-project/filter-project.pipe';
// tslint:disable-next-line:max-line-length
import { ActivitiesManagementComponent } from './components/options-sidebar/activities/activities-management/activities-management.component';

@NgModule({
Expand All @@ -48,7 +47,7 @@ import { ActivitiesManagementComponent } from './components/options-sidebar/acti
EmptyStateComponent,
GroupByDatePipe,
SearchProjectComponent,
FilterProjectPipe
FilterProjectPipe,
ActivitiesManagementComponent,
CreateActivityComponent,
ActivityListComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ describe('CreateActivityComponent', () => {
it('should create the component', () => {
expect(component).toBeTruthy();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ProjectService } from '../../../services/project.service';
import { of } from 'rxjs';
import { CreateProjectComponent } from '../../../components/shared/create-project/create-project.component';
import { ProjectListComponent } from '../../../components/shared/project-list/project-list.component';
import { FilterProjectPipe } from 'src/app/components/shared/pipes/filter-project/filter-project.pipe';

describe('ProjectManagementComponent', () => {
let component: ProjectManagementComponent;
Expand Down Expand Up @@ -45,7 +46,7 @@ describe('ProjectManagementComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ProjectManagementComponent, CreateProjectComponent, ProjectListComponent ],
declarations: [ ProjectManagementComponent, CreateProjectComponent, ProjectListComponent, FilterProjectPipe ],
providers: [ { provide: ProjectService, useValue: projectServiceStub }],
imports: [
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { By } from '@angular/platform-browser';
import { DebugElement, Component } from '@angular/core';
import { TimeClockComponent } from './time-clock.component';
import { ProjectListHoverComponent } from '../../shared/project-list-hover/project-list-hover.component';
import { FilterProjectPipe } from 'src/app/components/shared/pipes/filter-project/filter-project.pipe';

describe('TimeClockComponent', () => {
let component: TimeClockComponent;
Expand All @@ -11,7 +12,7 @@ describe('TimeClockComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TimeClockComponent, ProjectListHoverComponent]
declarations: [TimeClockComponent, ProjectListHoverComponent, FilterProjectPipe]
}).compileComponents();
}));

Expand Down Expand Up @@ -197,6 +198,13 @@ describe('TimeClockComponent', () => {
expect(component.secondsCounterRealTime).not.toEqual(0);
});

it('inside timer first if' , () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this test is doing?
Could you please explain what are you testing here?

component.secondsCounterRealTime = component.secondsCounterRealTime + 58;
component.timer();
expect(component.minuteCounterRealTime).toEqual(1);
expect(component.secondsCounterRealTime).toEqual(0);
});

/* ---------------------- ARRIVALS ------------------------------------- */
it('should execute intern methods of arrivals' , () => {
const currentDate = new Date();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ export class TimeClockComponent implements OnInit {
timer() {
this.secondsCounterRealTime += 1;
if ( this.secondsCounterRealTime === 59 ) {
this.minuteCounterRealTime += 1;
this.secondsCounterRealTime = 0;
console.log('entroooo');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console log please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

this.minuteCounterRealTime += 1; //1
this.secondsCounterRealTime = 0; //0
if ( this.minuteCounterRealTime === 59 ) {
this.hourCounterRealTime += 1;
this.minuteCounterRealTime = 0;
Expand Down
14 changes: 14 additions & 0 deletions src/app/components/shared/clock/clock.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,18 @@ describe('ClockComponent', () => {
expect(component.showClock).toHaveBeenCalled();
});

it('should be verify the init state of vars' , () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you testing here?

expect(component.hour).toEqual(0);
expect(component.minutes).toEqual(0);
expect(component.seconds).toEqual(0);
expect(component.displayTime).toBeFalsy();
});

it('should enter if and assign the value to vars' , () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you testing here?

component.showClock();
expect(component.hour).toEqual(0);
expect(component.minutes).toEqual(0);
expect(component.seconds).toEqual(0);
});

});
3 changes: 3 additions & 0 deletions src/app/components/shared/clock/clock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class ClockComponent implements OnInit {
constructor() {
this.showClock();
this.displayTime = false;
this.hour = 0;
this.minutes = 0;
this.seconds = 0;
setTimeout(() => {
this.displayTime = true;
}, 3000);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { FilterProjectPipe } from './filter-project.pipe';
import { Project } from '../../../../interfaces/project';

describe('FilterProjectPipe', () => {
it('create an instance', () => {
const pipe = new FilterProjectPipe();
expect(pipe).toBeTruthy();
});

it('test method of pipe', () => {
expect(new FilterProjectPipe().transform([] , '')).toEqual([]);
});

});
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Pipe, PipeTransform } from '@angular/core';
import { Project } from 'src/app/interfaces';

@Pipe({
name: 'filterProject'
})
export class FilterProjectPipe implements PipeTransform {

transform(value: any, arg: any): any {
transform(value: Project[] = [], arg: string): string[] {

const restultProjects = [];
for ( const projects of value ) {
if ( projects.name.toLowerCase().indexOf(arg.toLowerCase()) > -1 ) {
restultProjects.push(projects);
// tslint:disable-next-line: prefer-for-of
for ( let i = 0; i < value.length; i++ ) {
if ( value[i].name.toLowerCase().indexOf(arg.toLowerCase()) > -1 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement should be tested since this is the logic we want to make sure it's working.

restultProjects.push(value[i]);
}
}
return restultProjects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { async, ComponentFixture, TestBed } from "@angular/core/testing";

import { ProjectListHoverComponent } from "./project-list-hover.component";
import { FilterProjectPipe } from 'src/app/components/shared/pipes/filter-project/filter-project.pipe';

describe("ProjectListHoverComponent", () => {
let component: ProjectListHoverComponent;
let fixture: ComponentFixture<ProjectListHoverComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ProjectListHoverComponent]
declarations: [ProjectListHoverComponent, FilterProjectPipe]
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ProjectListComponent } from './project-list.component';
import { FilterProjectPipe } from 'src/app/components/shared/pipes/filter-project/filter-project.pipe';

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

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ProjectListComponent ]
declarations: [ ProjectListComponent, FilterProjectPipe ]
})
.compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ describe('SearchProjectComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('called method' , () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you testing here?

component.changeFilterProject.emit('angular');
component.filterProject = 'angular';
component.changeFilterValue();
expect(component.filterProject).toEqual('angular');
});
});