Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make projectService name consistent #2944

Merged
merged 1 commit into from
May 3, 2024
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
14 changes: 7 additions & 7 deletions src/app/core/services/merge-expenses.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('MergeExpensesService', () => {
let corporateCreditCardExpenseService: jasmine.SpyObj<CorporateCreditCardExpenseService>;
let customInputsService: jasmine.SpyObj<CustomInputsService>;
let humanizeCurrencyPipe: jasmine.SpyObj<HumanizeCurrencyPipe>;
let projectService: jasmine.SpyObj<ProjectsService>;
let projectsService: jasmine.SpyObj<ProjectsService>;
let categoriesService: jasmine.SpyObj<CategoriesService>;
let dateService: jasmine.SpyObj<DateService>;
let taxGroupService: jasmine.SpyObj<TaxGroupService>;
Expand All @@ -121,7 +121,7 @@ describe('MergeExpensesService', () => {
]);
const customInputsServiceSpy = jasmine.createSpyObj('CustomInputsService', ['getAll']);
const humanizeCurrencyPipeSpy = jasmine.createSpyObj('HumanizeCurrencyPipe', ['transform']);
const projectServiceSpy = jasmine.createSpyObj('ProjectsService', ['getAllActive']);
const projectsServiceSpy = jasmine.createSpyObj('ProjectsService', ['getAllActive']);
const categoriesServiceSpy = jasmine.createSpyObj('CategoriesService', ['getAll', 'filterRequired']);
const dateServiceSpy = jasmine.createSpyObj('DateService', ['isValidDate']);
const taxGroupServiceSpy = jasmine.createSpyObj('TaxGroupService', ['get']);
Expand All @@ -134,7 +134,7 @@ describe('MergeExpensesService', () => {
{ provide: CorporateCreditCardExpenseService, useValue: corporateCreditCardExpenseServiceSpy },
{ provide: CustomInputsService, useValue: customInputsServiceSpy },
{ provide: HumanizeCurrencyPipe, useValue: humanizeCurrencyPipeSpy },
{ provide: ProjectsService, useValue: projectServiceSpy },
{ provide: ProjectsService, useValue: projectsServiceSpy },
{ provide: CategoriesService, useValue: categoriesServiceSpy },
{ provide: DateService, useValue: dateServiceSpy },
{ provide: TaxGroupService, useValue: taxGroupServiceSpy },
Expand All @@ -148,7 +148,7 @@ describe('MergeExpensesService', () => {
) as jasmine.SpyObj<CorporateCreditCardExpenseService>;
customInputsService = TestBed.inject(CustomInputsService) as jasmine.SpyObj<CustomInputsService>;
humanizeCurrencyPipe = TestBed.inject(HumanizeCurrencyPipe) as jasmine.SpyObj<HumanizeCurrencyPipe>;
projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
categoriesService = TestBed.inject(CategoriesService) as jasmine.SpyObj<CategoriesService>;
dateService = TestBed.inject(DateService) as jasmine.SpyObj<DateService>;
taxGroupService = TestBed.inject(TaxGroupService) as jasmine.SpyObj<TaxGroupService>;
Expand Down Expand Up @@ -404,7 +404,7 @@ describe('MergeExpensesService', () => {

describe('formatProjectOptions():', () => {
it('should return the project options', (done) => {
projectService.getAllActive.and.returnValue(of(projectsV1Data));
projectsService.getAllActive.and.returnValue(of(projectsV1Data));
// @ts-ignore
mergeExpensesService.formatProjectOptions(projectOptionsData).subscribe((res) => {
expect(res).toEqual(projectOptionsData);
Expand All @@ -413,7 +413,7 @@ describe('MergeExpensesService', () => {
});

it('should return the project options with label as project name if id matches with option', (done) => {
projectService.getAllActive.and.returnValue(of(projectsV1Data));
projectsService.getAllActive.and.returnValue(of(projectsV1Data));
// @ts-ignore
mergeExpensesService.formatProjectOptions({ ...projectOptionsData, value: 257528 }).subscribe((res) => {
expect(res).toEqual({ label: 'Customer Mapped Project', value: 257528 });
Expand All @@ -422,7 +422,7 @@ describe('MergeExpensesService', () => {
});

it('should return the project options when project is not present', (done) => {
projectService.getAllActive.and.returnValue(of([]));
projectsService.getAllActive.and.returnValue(of([]));
// @ts-ignore
mergeExpensesService.formatProjectOptions({ label: null, value: null }).subscribe((res) => {
expect(res).toEqual({ label: undefined, value: null });
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/merge-expenses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MergeExpensesService {
private corporateCreditCardExpenseService: CorporateCreditCardExpenseService,
private customInputsService: CustomInputsService,
private humanizeCurrency: HumanizeCurrencyPipe,
private projectService: ProjectsService,
private projectsService: ProjectsService,
private categoriesService: CategoriesService,
private dateService: DateService,
private taxGroupService: TaxGroupService
Expand Down Expand Up @@ -748,7 +748,7 @@ export class MergeExpensesService {
}

private formatProjectOptions(option: MergeExpensesOption<number>): Observable<MergeExpensesOption<number>> {
const projects$ = this.projectService.getAllActive().pipe(shareReplay(1));
const projects$ = this.projectsService.getAllActive().pipe(shareReplay(1));
return projects$.pipe(
map((projects) => {
const index = projects.map((project) => project.id).indexOf(option.value);
Expand Down
24 changes: 12 additions & 12 deletions src/app/core/services/projects.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const fixDate = (data) =>
}));

describe('ProjectsService', () => {
let projectService: ProjectsService;
let projectsService: ProjectsService;
let apiService: jasmine.SpyObj<ApiService>;
let apiV2Service: jasmine.SpyObj<ApiV2Service>;

Expand All @@ -46,18 +46,18 @@ describe('ProjectsService', () => {
},
],
});
projectService = TestBed.inject(ProjectsService);
projectsService = TestBed.inject(ProjectsService);
apiService = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
apiV2Service = TestBed.inject(ApiV2Service) as jasmine.SpyObj<ApiV2Service>;
});

it('should be created', () => {
expect(projectService).toBeTruthy();
expect(projectsService).toBeTruthy();
});

it('should be able to fetch project by id', (done) => {
apiV2Service.get.and.returnValue(of(apiV2ResponseSingle));
projectService.getbyId(257528).subscribe((res) => {
projectsService.getbyId(257528).subscribe((res) => {
expect(res).toEqual(fixDate(apiV2ResponseSingle.data)[0]);
done();
});
Expand All @@ -71,7 +71,7 @@ describe('ProjectsService', () => {

it('should be able to fetch all active projects', (done) => {
apiService.get.and.returnValue(of(apiResponseActiveOnly));
projectService.getAllActive().subscribe((res) => {
projectsService.getAllActive().subscribe((res) => {
expect(res).toEqual(expectedReponseActiveOnly);
done();
});
Expand All @@ -86,7 +86,7 @@ describe('ProjectsService', () => {
it('should be able to fetch data when no params provided', (done) => {
apiV2Service.get.and.returnValue(of(apiV2ResponseMultiple));

projectService.getByParamsUnformatted({}).subscribe((res) => {
projectsService.getByParamsUnformatted({}).subscribe((res) => {
expect(res).toEqual(fixDate(apiV2ResponseMultiple.data));
done();
});
Expand All @@ -95,7 +95,7 @@ describe('ProjectsService', () => {
it('should be able to fetch data when params are provided', (done) => {
apiV2Service.get.and.returnValue(of(apiV2ResponseMultiple));

const result = projectService.getByParamsUnformatted(testProjectParams);
const result = projectsService.getByParamsUnformatted(testProjectParams);

result.subscribe((res) => {
expect(res).toEqual(expectedProjectsResponse);
Expand All @@ -107,19 +107,19 @@ describe('ProjectsService', () => {
});

it('should category list after filter as per project passed', () => {
const result = projectService.getAllowedOrgCategoryIds(testProjectV2, testActiveCategoryList);
const result = projectsService.getAllowedOrgCategoryIds(testProjectV2, testActiveCategoryList);
expect(result).toEqual(allowedActiveCategories);
});

it('should return whole category list if project passed is not present', () => {
const result = projectService.getAllowedOrgCategoryIds(null, testActiveCategoryList);
const result = projectsService.getAllowedOrgCategoryIds(null, testActiveCategoryList);
expect(result).toEqual(testActiveCategoryList);
});

it('should get project count restricted by a set of category IDs', (done) => {
apiService.get.and.returnValue(of(apiResponseActiveOnly));

const result = projectService.getProjectCount({ categoryIds: testCategoryIds });
const result = projectsService.getProjectCount({ categoryIds: testCategoryIds });
result.subscribe((res) => {
expect(res).toEqual(2);
done();
Expand All @@ -129,8 +129,8 @@ describe('ProjectsService', () => {
it('should get project count not restricted by a set of category IDs', (done) => {
apiService.get.and.returnValue(of(apiResponseActiveOnly));

const resultWithOutParam = projectService.getProjectCount();
const resultWithParam = projectService.getProjectCount({ categoryIds: null });
const resultWithOutParam = projectsService.getProjectCount();
const resultWithParam = projectsService.getProjectCount({ categoryIds: null });

resultWithOutParam.subscribe((res) => {
expect(res).toEqual(apiResponseActiveOnly.length);
Expand Down
8 changes: 4 additions & 4 deletions src/app/core/services/recently-used-items.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { recentUsedCategoriesRes } from '../mock-data/org-category-list-item.dat
describe('RecentlyUsedItemsService', () => {
let recentlyUsedItemsService: RecentlyUsedItemsService;
let apiService: jasmine.SpyObj<ApiService>;
let projectService: jasmine.SpyObj<ProjectsService>;
let projectsService: jasmine.SpyObj<ProjectsService>;

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -38,7 +38,7 @@ describe('RecentlyUsedItemsService', () => {
});
recentlyUsedItemsService = TestBed.inject(RecentlyUsedItemsService);
apiService = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
});

it('should be created', () => {
Expand All @@ -56,14 +56,14 @@ describe('RecentlyUsedItemsService', () => {

describe('getRecentlyUsedProjects():', () => {
it('should get all the recently used projects', (done) => {
projectService.getByParamsUnformatted.and.returnValue(of(recentlyUsedProjectRes));
projectsService.getByParamsUnformatted.and.returnValue(of(recentlyUsedProjectRes));
const config = {
recentValues: recentlyUsedRes,
eou: apiEouRes,
categoryIds: ['16558', '16559', '16560', '16561', '16562'],
};
recentlyUsedItemsService.getRecentlyUsedProjects(config).subscribe((res) => {
expect(projectService.getByParamsUnformatted).toHaveBeenCalledOnceWith({
expect(projectsService.getByParamsUnformatted).toHaveBeenCalledOnceWith({
orgId: config.eou.ou.org_id,
active: true,
sortDirection: 'asc',
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/recently-used-items.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Currency, CurrencyName } from '../models/currency.model';
providedIn: 'root',
})
export class RecentlyUsedItemsService {
constructor(private apiService: ApiService, private projectService: ProjectsService) {}
constructor(private apiService: ApiService, private projectsService: ProjectsService) {}

getRecentlyUsed(): Observable<RecentlyUsed> {
return this.apiService.get('/recently_used');
Expand All @@ -30,7 +30,7 @@ export class RecentlyUsedItemsService {
config.recentValues.recent_project_ids.length > 0 &&
config.eou
) {
return this.projectService
return this.projectsService
.getByParamsUnformatted({
orgId: config.eou.ou.org_id,
active: true,
Expand Down
8 changes: 4 additions & 4 deletions src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class AddEditMileagePage implements OnInit {
private reportService: ReportService,
private platformReportService: ReportsService,
private fb: FormBuilder,
private projectService: ProjectsService,
private projectsService: ProjectsService,
private mileageService: MileageService,
private mileageRatesService: MileageRatesService,
private transactionsOutboxService: TransactionsOutboxService,
Expand Down Expand Up @@ -467,7 +467,7 @@ export class AddEditMileagePage implements OnInit {
concatMap((project: ProjectV2) =>
activeCategories$.pipe(
map((activeCategories: OrgCategory[]) =>
this.projectService.getAllowedOrgCategoryIds(project, activeCategories)
this.projectsService.getAllowedOrgCategoryIds(project, activeCategories)
)
)
),
Expand Down Expand Up @@ -1160,7 +1160,7 @@ export class AddEditMileagePage implements OnInit {
}),
switchMap((projectId) => {
if (projectId) {
return this.projectService.getbyId(projectId);
return this.projectsService.getbyId(projectId);
} else {
return of(null);
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ export class AddEditMileagePage implements OnInit {
this.setupFilteredCategories(this.subCategories$);
this.projectCategoryIds$ = this.getProjectCategoryIds();
this.isProjectVisible$ = this.projectCategoryIds$.pipe(
switchMap((projectCategoryIds) => this.projectService.getProjectCount({ categoryIds: projectCategoryIds })),
switchMap((projectCategoryIds) => this.projectsService.getProjectCount({ categoryIds: projectCategoryIds })),
map((projectCount) => projectCount > 0)
);
this.comments$ = this.statusService.find('transactions', this.activatedRoute.snapshot.params.id as string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('AddEditPerDiemPage', () => {
'removeTransaction',
]);
const platformReportsServiceSpy = jasmine.createSpyObj('ReportsService', ['getAllReportsByParams']);
const projectServiceSpy = jasmine.createSpyObj('ProjectService', [
const projectsServiceSpy = jasmine.createSpyObj('ProjectService', [
'getAllowedOrgCategoryIds',
'getProjectCount',
'getbyId',
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('AddEditPerDiemPage', () => {
},
{
provide: ProjectsService,
useValue: projectServiceSpy,
useValue: projectsServiceSpy,
},
{
provide: TransactionsOutboxService,
Expand Down
8 changes: 4 additions & 4 deletions src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class AddEditPerDiemPage implements OnInit {
private currencyService: CurrencyService,
private reportService: ReportService,
private platformReportService: ReportsService,
private projectService: ProjectsService,
private projectsService: ProjectsService,
private transactionsOutboxService: TransactionsOutboxService,
private transactionService: TransactionService,
private authService: AuthService,
Expand Down Expand Up @@ -689,7 +689,7 @@ export class AddEditPerDiemPage implements OnInit {
startWith(this.fg.controls.project.value),
concatMap((project: ProjectV2) =>
activeCategories$.pipe(
map((activeCategories) => this.projectService.getAllowedOrgCategoryIds(project, activeCategories))
map((activeCategories) => this.projectsService.getAllowedOrgCategoryIds(project, activeCategories))
)
),
map((categories) => categories.map((category) => ({ label: category.sub_category, value: category })))
Expand Down Expand Up @@ -1008,7 +1008,7 @@ export class AddEditPerDiemPage implements OnInit {

this.projectCategoryIds$ = this.getProjectCategoryIds();
this.isProjectVisible$ = this.projectCategoryIds$.pipe(
switchMap((projectCategoryIds) => this.projectService.getProjectCount({ categoryIds: projectCategoryIds })),
switchMap((projectCategoryIds) => this.projectsService.getProjectCount({ categoryIds: projectCategoryIds })),
map((projectCount) => projectCount > 0)
);
this.comments$ = this.statusService.find('transactions', this.activatedRoute.snapshot.params.id as string);
Expand Down Expand Up @@ -1309,7 +1309,7 @@ export class AddEditPerDiemPage implements OnInit {
}),
switchMap((projectId) => {
if (projectId) {
return this.projectService.getbyId(projectId);
return this.projectsService.getbyId(projectId);
} else {
return of(null);
}
Expand Down
Loading
Loading