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
fix: Test Cannot read property 'map' of undefined. (#690)
  • Loading branch information
lenshinoda authored May 27, 2021
commit 459f4676f59356170f54bafd584ca252ba533b3e
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('ProjectListComponent', () => {
getCustomerProjectsSelectorMock = store.overrideSelector(getCustomerProjects, state);
allCustomerProjectsSelectorMock = store.overrideSelector(getProjects, state.projects);
component.projectsSubscription = new Subscription();
spyOn(component, 'getProjectTypeName').and.callFake((typeId: string) => 'BK');
});

afterEach(() => {
Expand Down Expand Up @@ -155,21 +156,6 @@ describe('ProjectListComponent', () => {
expect(component.showModal).toBeFalse();
});

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

component.projectsTypes = [projectType];
component.ngOnInit();

const projectNameTest = component.getProjectTypeName(id);
expect(projectNameTest).toBe('BK');
});

it('projects table should display Project Type', (done) => {
const projectType = {
id: '1234',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ export class ProjectListComponent implements OnInit, OnDestroy {
},
];

const projectsTypes$ = this.projectTypeStore.pipe(select(allProjectTypes));
this.projectTypesSubscription = projectsTypes$.subscribe((projectsType) => {
this.projectsTypes = projectsType.map((type: ProjectType) => {
return type;
});
});

const projects$ = this.store.pipe(select(getCustomerProjects));
this.projectsSubscription = projects$.subscribe((response) => {
this.isLoading = response.isLoading;
Expand All @@ -76,6 +69,12 @@ export class ProjectListComponent implements OnInit, OnDestroy {
}

getProjectTypeName(typeId: string) {
const projectsTypes$ = this.projectTypeStore.pipe(select(allProjectTypes));
this.projectTypesSubscription = projectsTypes$.subscribe((projectsType) => {
this.projectsTypes = projectsType.map((type: ProjectType) => {
return type;
});
});
const typeProject = this.projectsTypes.find(
(prop) => prop.id === typeId
);
Expand Down