Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,5 @@ export function activityManagementReducer(state: ActivityState = initialState, a
};
}

default:
return state;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as selectors from './activity-management.selectors';

describe('ActivityManagement Selectors', () => {

it('reads activityIdtoEdit from state', () => {
const activityId = 'id';
const activityIdFound = selectors.activityIdtoEdit.projector({ activityIdToEdit: activityId });
expect(activityIdFound).toBe(activityId);
});

it('returns the activity with id that matches from the list', () => {
const activityId = 'id';
const activities = [{id: 'id', name: 'abc', description: 'xxx'},
{id: '2', name: 'xyz', description: 'yyy'}];
const activityFound = selectors.getActivityById.projector(activities, activityId);
expect(activityFound).toEqual(activities[0]);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing';

import { CreateCustomerComponent } from './create-customer';
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
import { LoadCustomers, ResetCustomerToEdit } from './../../../../store/customer-management.actions';
import { LoadCustomers, ResetCustomerToEdit, UpdateCustomer } from './../../../../store/customer-management.actions';
import { Customer } from 'src/app/modules/shared/models';

describe('CreateCustomerComponent', () => {
Expand All @@ -22,7 +22,6 @@ describe('CreateCustomerComponent', () => {
const customerData: Customer = {
name: 'aa',
description: 'bb',
tenant_id: 'cc',
};

beforeEach(async(() => {
Expand All @@ -48,6 +47,15 @@ describe('CreateCustomerComponent', () => {
expect(component).toBeTruthy();
});

it('onSubmit dispatchs UpdateCustomer action', () => {
spyOn(store, 'dispatch');
component.customerToEdit = {id: 'id', name: 'xyz'};

component.onSubmit({ name: 'abc'});

expect(store.dispatch).toHaveBeenCalledWith(new UpdateCustomer({id: 'id', name: 'abc'}));
});

it('should call resetCustomerForm', () => {
spyOn(component.customerForm, 'reset');

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

import { provideMockStore, MockStore } from '@ngrx/store/testing';
import { NgxPaginationModule } from 'ngx-pagination';

import { DeleteProjectType, SetProjectTypeToEdit } from './../../store/project-type.actions';
import { allProjectTypes, ProjectTypeState } from '../../store';
import { ProjectTypeListComponent } from './project-type-list.component';

Expand Down Expand Up @@ -57,4 +57,20 @@ describe('ProjectTypeTableListComponent', () => {
expect(component.projectTypes).toBe(state.data);
});

it('dispatchs DeleteProjectType on deleteProjectType', () => {
spyOn(store, 'dispatch');

component.deleteProjectType('id');

expect(store.dispatch).toHaveBeenCalledWith(new DeleteProjectType('id'));
});

it('dispatchs UpdateProjectType on updateProjectType', () => {
spyOn(store, 'dispatch');

component.updateProjectType('id');

expect(store.dispatch).toHaveBeenCalledWith(new SetProjectTypeToEdit('id'));
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('CustomerService', () => {
));

it('create customer using POST from baseUrl', () => {
const customer: Customer[] = [{ name: 'aa', description: 'bb', tenant_id: 'cc' }];
const customer: Customer[] = [{ name: 'aa', description: 'bb'}];

service.baseUrl = 'customers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ describe('CustomerManagmentActions', () => {
const createActivity = new actions.CreateCustomer({
name: 'aa',
description: 'bb',
tenant_id: 'cc',
});
expect(createActivity.type).toEqual(actions.CustomerManagementActionTypes.CREATE_CUSTOMER);
});
Expand All @@ -14,7 +13,6 @@ describe('CustomerManagmentActions', () => {
const createActivitySuccess = new actions.CreateCustomerSuccess({
name: 'aa',
description: 'bb',
tenant_id: 'cc',
});
expect(createActivitySuccess.type).toEqual(actions.CustomerManagementActionTypes.CREATE_CUSTOMER_SUCCESS);
});
Expand Down Expand Up @@ -53,7 +51,6 @@ describe('CustomerManagmentActions', () => {
const updateCustomer = new actions.UpdateCustomer({
name: 'aa',
description: 'bb',
tenant_id: 'cc',
});
expect(updateCustomer.type).toEqual(actions.CustomerManagementActionTypes.UPDATE_CUSTOMER);
});
Expand All @@ -62,7 +59,6 @@ describe('CustomerManagmentActions', () => {
const updateCustomerSucess = new actions.UpdateCustomerSuccess({
name: 'aa',
description: 'bb',
tenant_id: 'cc',
});
expect(updateCustomerSucess.type).toEqual(actions.CustomerManagementActionTypes.UPDATE_CUSTOMER_SUCCESS);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as actions from './customer-management.actions';

describe('customerManagementReducer', () => {
const initialState: CustomerState = { data: [], isLoading: false, message: '', customerIdToEdit: '' };
const customer: Customer = { name: 'aa', description: 'bb', tenant_id: 'cc' };
const customer: Customer = { name: 'aa', description: 'bb'};

it('on LoadCustomer, isLoading is true ', () => {
const action = new actions.LoadCustomers();
Expand Down
1 change: 0 additions & 1 deletion src/app/modules/shared/models/customer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ export interface Customer {
id?: string;
name: string;
description?: string;
tenant_id: string;
}
13 changes: 0 additions & 13 deletions src/app/modules/time-clock/store/entry.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ import { EntryState } from './entry.reducer';

const getEntryState = createFeatureSelector('entries');

export const allEntries = createSelector(getEntryState, (state: EntryState) => {
return state;
});

export const selectProjects = (state) => state.projects.projectList;
export const selectEntries = (state) => state.entries.active;

export const getActiveTimeEntry = createSelector(getEntryState, (state: EntryState) => {
return state.active;
});

export const getStatusMessage = createSelector(getEntryState, (state: EntryState) => {
if (state) {
return state.message;
}
});