Skip to content
Closed
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
Next Next commit
#3 added project service in list
  • Loading branch information
daros10 committed Apr 1, 2020
commit 15217105591c7512692df588d261281674efc2b8
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { SearchProjectComponent } from './modules/shared/components/search-proje
CreateActivityComponent,
ActivityListComponent,
FilterProjectPipe,
SearchProjectComponent
SearchProjectComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ describe('FilterProjectPipe', () => {
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,7 +1,10 @@
<app-search-project (changeFilterProject)="filterProjects = $event"></app-search-project>
<ul class="list-group content-projects">
<li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center" *ngFor="let item of projects | filterProject:filterProjects; let i = index" (mouseenter)="showButton = i" (mouseleave)="showButton = -1" (click)="clockIn(item.id)" [ngClass]="{ active: selectedId === item.id }">
{{ item.name }}
<span *ngIf="showButton === i && selectedId !== item.id" class="badge badge-light">Clock In</span>
</li>
<div *ngFor="let item of listProjects | filterProject:filterProjects; let i = index" class="container">
<li *ngIf="item.status === 'Active'" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center" (mouseenter)="showButton = i" (mouseleave)="showButton = -1" (click)="clockIn(item.id)" [ngClass]="{ active: selectedId === item.id }">
{{ item.name }}
<span *ngIf="showButton != i" class="badge badge-success">{{ item.status }}</span>
<span *ngIf="showButton === i && selectedId !== item.id" class="badge badge-light">Clock In</span>
</li>
</div>
</ul>
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';

import { ProjectListHoverComponent } from './project-list-hover.component';
import { FilterProjectPipe } from 'src/app/modules/shared/pipes/filter-project/filter-project.pipe';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { ProjectService } from 'src/app/modules/project-management/services/project.service';

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

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

Expand All @@ -19,6 +22,16 @@ describe('ProjectListHoverComponent', () => {
fixture.detectChanges();
});

it('should be created', () => {
const service: ProjectService = TestBed.get(ProjectService);
expect(service).toBeTruthy();
});

it('should have add function', () => {
const service: ProjectService = TestBed.get(ProjectService);
expect(service.getProjects).toBeTruthy();
});

it('should create', () => {
expect(component).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ export class ProjectListHoverComponent implements OnInit {
filterProjects: string = '';
listProjects: Project[] = [];

constructor() {
constructor(private projectService: ProjectService) {
this.showButton = -1;
}

ngOnInit(): void { }
ngOnInit(): void {
this.projectService.getProjects().subscribe(data => this.listProjects = data);
}

clockIn(id: string) {
this.selectedId = id;
Expand Down
17 changes: 15 additions & 2 deletions src/app/modules/time-clock/pages/time-clock.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { DebugElement, inject } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TimeClockComponent } from './time-clock.component';
import { ProjectListHoverComponent } from '../components';
import { FilterProjectPipe } from '../../shared/pipes/filter-project/filter-project.pipe';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ProjectService } from '../../project-management/services/project.service';

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

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

Expand All @@ -24,6 +27,16 @@ describe('TimeClockComponent', () => {
});


it('should be created', () => {
const service: ProjectService = TestBed.get(ProjectService);
expect(service).toBeTruthy();
});

it('should have add function', () => {
const service: ProjectService = TestBed.get(ProjectService);
expect(service.getProjects).toBeTruthy();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
Expand Down