Skip to content

Commit e2ac439

Browse files
committed
#3 find project
1 parent de4fbd6 commit e2ac439

File tree

12 files changed

+56
-13
lines changed

12 files changed

+56
-13
lines changed

src/app/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { EmptyStateComponent } from './components/shared/empty-state/empty-state
2525
import { GroupByDatePipe } from './components/shared/pipes/group-by-date/group-by-date.pipe';
2626
import { SearchProjectComponent } from './components/shared/search-project/search-project.component';
2727
import { FilterProjectPipe } from './components/shared/pipes/filter-project/filter-project.pipe';
28-
// tslint:disable-next-line:max-line-length
2928
import { ActivitiesManagementComponent } from './components/options-sidebar/activities/activities-management/activities-management.component';
3029

3130
@NgModule({
@@ -48,7 +47,7 @@ import { ActivitiesManagementComponent } from './components/options-sidebar/acti
4847
EmptyStateComponent,
4948
GroupByDatePipe,
5049
SearchProjectComponent,
51-
FilterProjectPipe
50+
FilterProjectPipe,
5251
ActivitiesManagementComponent,
5352
CreateActivityComponent,
5453
ActivityListComponent

src/app/components/options-sidebar/activities/create-activity/create-activity.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ describe('CreateActivityComponent', () => {
1818
it('should create the component', () => {
1919
expect(component).toBeTruthy();
2020
});
21-
2221
});

src/app/components/options-sidebar/project-management/project-management.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ProjectService } from '../../../services/project.service';
77
import { of } from 'rxjs';
88
import { CreateProjectComponent } from '../../../components/shared/create-project/create-project.component';
99
import { ProjectListComponent } from '../../../components/shared/project-list/project-list.component';
10+
import { FilterProjectPipe } from 'src/app/components/shared/pipes/filter-project/filter-project.pipe';
1011

1112
describe('ProjectManagementComponent', () => {
1213
let component: ProjectManagementComponent;
@@ -45,7 +46,7 @@ describe('ProjectManagementComponent', () => {
4546

4647
beforeEach(async(() => {
4748
TestBed.configureTestingModule({
48-
declarations: [ ProjectManagementComponent, CreateProjectComponent, ProjectListComponent ],
49+
declarations: [ ProjectManagementComponent, CreateProjectComponent, ProjectListComponent, FilterProjectPipe ],
4950
providers: [ { provide: ProjectService, useValue: projectServiceStub }],
5051
imports: [
5152
FormsModule,

src/app/components/options-sidebar/time-clock/time-clock.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { By } from '@angular/platform-browser';
33
import { DebugElement, Component } from '@angular/core';
44
import { TimeClockComponent } from './time-clock.component';
55
import { ProjectListHoverComponent } from '../../shared/project-list-hover/project-list-hover.component';
6+
import { FilterProjectPipe } from 'src/app/components/shared/pipes/filter-project/filter-project.pipe';
67

78
describe('TimeClockComponent', () => {
89
let component: TimeClockComponent;
@@ -11,7 +12,7 @@ describe('TimeClockComponent', () => {
1112

1213
beforeEach(async(() => {
1314
TestBed.configureTestingModule({
14-
declarations: [TimeClockComponent, ProjectListHoverComponent]
15+
declarations: [TimeClockComponent, ProjectListHoverComponent, FilterProjectPipe]
1516
}).compileComponents();
1617
}));
1718

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

201+
it('inside timer first if' , () => {
202+
component.secondsCounterRealTime = component.secondsCounterRealTime + 58;
203+
component.timer();
204+
expect(component.minuteCounterRealTime).toEqual(1);
205+
expect(component.secondsCounterRealTime).toEqual(0);
206+
});
207+
200208
/* ---------------------- ARRIVALS ------------------------------------- */
201209
it('should execute intern methods of arrivals' , () => {
202210
const currentDate = new Date();

src/app/components/options-sidebar/time-clock/time-clock.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ export class TimeClockComponent implements OnInit {
9999
timer() {
100100
this.secondsCounterRealTime += 1;
101101
if ( this.secondsCounterRealTime === 59 ) {
102-
this.minuteCounterRealTime += 1;
103-
this.secondsCounterRealTime = 0;
102+
console.log('entroooo');
103+
this.minuteCounterRealTime += 1; //1
104+
this.secondsCounterRealTime = 0; //0
104105
if ( this.minuteCounterRealTime === 59 ) {
105106
this.hourCounterRealTime += 1;
106107
this.minuteCounterRealTime = 0;

src/app/components/shared/clock/clock.component.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,18 @@ describe('ClockComponent', () => {
4545
expect(component.showClock).toHaveBeenCalled();
4646
});
4747

48+
it('should be verify the init state of vars' , () => {
49+
expect(component.hour).toEqual(0);
50+
expect(component.minutes).toEqual(0);
51+
expect(component.seconds).toEqual(0);
52+
expect(component.displayTime).toBeFalsy();
53+
});
54+
55+
it('should enter if and assign the value to vars' , () => {
56+
component.showClock();
57+
expect(component.hour).toEqual(0);
58+
expect(component.minutes).toEqual(0);
59+
expect(component.seconds).toEqual(0);
60+
});
61+
4862
});

src/app/components/shared/clock/clock.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export class ClockComponent implements OnInit {
1717
constructor() {
1818
this.showClock();
1919
this.displayTime = false;
20+
this.hour = 0;
21+
this.minutes = 0;
22+
this.seconds = 0;
2023
setTimeout(() => {
2124
this.displayTime = true;
2225
}, 3000);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { FilterProjectPipe } from './filter-project.pipe';
2+
import { Project } from '../../../../interfaces/project';
23

34
describe('FilterProjectPipe', () => {
45
it('create an instance', () => {
56
const pipe = new FilterProjectPipe();
67
expect(pipe).toBeTruthy();
78
});
9+
10+
it('test method of pipe', () => {
11+
expect(new FilterProjectPipe().transform([] , '')).toEqual([]);
12+
});
13+
814
});

src/app/components/shared/pipes/filter-project/filter-project.pipe.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { Pipe, PipeTransform } from '@angular/core';
2+
import { Project } from 'src/app/interfaces';
23

34
@Pipe({
45
name: 'filterProject'
56
})
67
export class FilterProjectPipe implements PipeTransform {
78

8-
transform(value: any, arg: any): any {
9+
transform(value: Project[] = [], arg: string): string[] {
10+
911
const restultProjects = [];
10-
for ( const projects of value ) {
11-
if ( projects.name.toLowerCase().indexOf(arg.toLowerCase()) > -1 ) {
12-
restultProjects.push(projects);
12+
// tslint:disable-next-line: prefer-for-of
13+
for ( let i = 0; i < value.length; i++ ) {
14+
if ( value[i].name.toLowerCase().indexOf(arg.toLowerCase()) > -1 ) {
15+
restultProjects.push(value[i]);
1316
}
1417
}
1518
return restultProjects;

src/app/components/shared/project-list-hover/project-list-hover.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { async, ComponentFixture, TestBed } from "@angular/core/testing";
22

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

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

910
beforeEach(async(() => {
1011
TestBed.configureTestingModule({
11-
declarations: [ProjectListHoverComponent]
12+
declarations: [ProjectListHoverComponent, FilterProjectPipe]
1213
}).compileComponents();
1314
}));
1415

0 commit comments

Comments
 (0)