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
fix: TT-24 rename some variables
  • Loading branch information
lenshinoda committed May 18, 2021
commit 3e2fb25997d71e67e9f9fdf966b688106ca23924
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<tr class="d-flex" *ngFor="let project of projects">
<td class="col-sm-4">{{ project.id }}</td>
<td class="col-sm-3">{{ project.name }}</td>
<td class="col-sm-3">{{ getProjectType(project.project_type_id) }}</td>
<td class="col-sm-3">{{ getProjectTypeName(project.project_type_id) }}</td>
<td class="col-sm-1 text-center">
<button type="button" class="btn btn-sm btn-primary" (click)="updateProject(project)">
<i class="fa fa-pencil fa-xs"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,28 @@ describe('ProjectListComponent', () => {
});

it('getProjectType should be called to display it in projects table', () => {
const nameType = {
const projectType = {
id: '1234',
name: 'BK',
description: 'test',
};
const id = '1234';
component.projectsTypes = [nameType];

component.projectsTypes = [projectType];
component.ngOnInit();
const nameTest = component.getProjectType(id);
expect(nameTest).toBe('BK');

const projectNameTest = component.getProjectTypeName(id);
expect(projectNameTest).toBe('BK');
Copy link
Collaborator Author

@lenshinoda lenshinoda May 18, 2021

Choose a reason for hiding this comment

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

I am testing ('BK') here because the input of function getProjectTypeName is the project_type_id and it returns the name of the project type to render it on the table.

});

it('projects table should display Project Type', (done) => {
const nameType = {
const projectType = {
id: '1234',
name: 'BK',
description: 'test',
};
component.projectsTypes = [nameType];

component.projectsTypes = [projectType];
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ export class ProjectListComponent implements OnInit, OnDestroy {
}
}

getProjectType(typeId: string) {
const typeName = this.projectsTypes.find(
getProjectTypeName(typeId: string) {
const typeProject = this.projectsTypes.find(
(prop) => prop.id === typeId
);
return typeName !== undefined ? typeName.name : '';
return typeProject !== undefined ? typeProject.name : '';
}

updateProject(project) {
Expand Down