diff --git a/src/app/modules/activities-management/store/activity-management.reducers.ts b/src/app/modules/activities-management/store/activity-management.reducers.ts index 6ef86f5dc..bf2b9bee8 100644 --- a/src/app/modules/activities-management/store/activity-management.reducers.ts +++ b/src/app/modules/activities-management/store/activity-management.reducers.ts @@ -133,7 +133,5 @@ export function activityManagementReducer(state: ActivityState = initialState, a }; } - default: - return state; } } diff --git a/src/app/modules/activities-management/store/activity-management.selectors.spec.ts b/src/app/modules/activities-management/store/activity-management.selectors.spec.ts new file mode 100644 index 000000000..8b5539bee --- /dev/null +++ b/src/app/modules/activities-management/store/activity-management.selectors.spec.ts @@ -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]); + }); + +}); diff --git a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts index ad83e65d9..cca6afbf9 100644 --- a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts +++ b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts @@ -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', () => { @@ -22,7 +22,6 @@ describe('CreateCustomerComponent', () => { const customerData: Customer = { name: 'aa', description: 'bb', - tenant_id: 'cc', }; beforeEach(async(() => { @@ -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'); diff --git a/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts b/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts index f51c0450a..21559c777 100644 --- a/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts +++ b/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts @@ -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'; @@ -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')); + }); + }); diff --git a/src/app/modules/customer-management/services/customer.service.spec.ts b/src/app/modules/customer-management/services/customer.service.spec.ts index 923477add..2a5511a7a 100644 --- a/src/app/modules/customer-management/services/customer.service.spec.ts +++ b/src/app/modules/customer-management/services/customer.service.spec.ts @@ -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'; diff --git a/src/app/modules/customer-management/store/customer-management.actions.spec.ts b/src/app/modules/customer-management/store/customer-management.actions.spec.ts index 07bbd5352..5e38228ea 100644 --- a/src/app/modules/customer-management/store/customer-management.actions.spec.ts +++ b/src/app/modules/customer-management/store/customer-management.actions.spec.ts @@ -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); }); @@ -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); }); @@ -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); }); @@ -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); }); diff --git a/src/app/modules/customer-management/store/customer-management.reducers.spec.ts b/src/app/modules/customer-management/store/customer-management.reducers.spec.ts index c2ca5d2b6..14cab351a 100644 --- a/src/app/modules/customer-management/store/customer-management.reducers.spec.ts +++ b/src/app/modules/customer-management/store/customer-management.reducers.spec.ts @@ -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(); diff --git a/src/app/modules/shared/models/customer.model.ts b/src/app/modules/shared/models/customer.model.ts index f70b429a7..67337e5d9 100644 --- a/src/app/modules/shared/models/customer.model.ts +++ b/src/app/modules/shared/models/customer.model.ts @@ -2,5 +2,4 @@ export interface Customer { id?: string; name: string; description?: string; - tenant_id: string; } diff --git a/src/app/modules/time-clock/store/entry.selectors.ts b/src/app/modules/time-clock/store/entry.selectors.ts index 51b9e32a5..1b479c91c 100644 --- a/src/app/modules/time-clock/store/entry.selectors.ts +++ b/src/app/modules/time-clock/store/entry.selectors.ts @@ -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; - } -});