diff --git a/src/app/core/services/split-expense.service.spec.ts b/src/app/core/services/split-expense.service.spec.ts index c98e9a0f41..c76427202c 100644 --- a/src/app/core/services/split-expense.service.spec.ts +++ b/src/app/core/services/split-expense.service.spec.ts @@ -92,7 +92,6 @@ describe('SplitExpenseService', () => { beforeEach(() => { const transactionServiceSpy = jasmine.createSpyObj('TransactionService', [ - 'uploadBase64File', 'checkPolicy', 'upsert', 'transformRawExpense', @@ -187,7 +186,7 @@ describe('SplitExpenseService', () => { }); }); - describe('formatDisplayName(): ', () => { + describe('formatDisplayName():', () => { it('should get display name from list of categories', () => { categoriesService.filterByOrgCategoryId.and.returnValue(transformedOrgCategories[0]); const model = 141295; @@ -197,11 +196,12 @@ describe('SplitExpenseService', () => { ); expect(categoriesService.filterByOrgCategoryId).toHaveBeenCalledOnceWith(model, transformedOrgCategories); }); + it('should return undefined if filterByOrgCategoryId returns undefined', () => { categoriesService.filterByOrgCategoryId.and.returnValue(undefined); const model = 141295; - expect(splitExpenseService.formatDisplayName(model, transformedOrgCategories)).toEqual(undefined); + expect(splitExpenseService.formatDisplayName(model, transformedOrgCategories)).toBeUndefined(); expect(categoriesService.filterByOrgCategoryId).toHaveBeenCalledOnceWith(model, transformedOrgCategories); }); }); @@ -503,7 +503,7 @@ describe('SplitExpenseService', () => { splitExpenseService .handleSplitPolicyCheck(txnList, fileObject4, txnDataPayload, { reportId: null, - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }) .subscribe((res) => { expect(res).toEqual(splitPolicyExp1); @@ -514,7 +514,7 @@ describe('SplitExpenseService', () => { ['fijCeF0G0jTl'], { reportId: null, - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, } ); expect(expensesService.splitExpenseCheckPolicies).toHaveBeenCalledOnceWith(splitPayloadData1); @@ -606,7 +606,7 @@ describe('SplitExpenseService', () => { const mockPlatformPayload = cloneDeep(splitPayloadData2); const reportAndUnspecifiedCategoryParams = { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }; const res = splitExpenseService.transformSplitTo( mockSplitTxn, @@ -630,7 +630,7 @@ describe('SplitExpenseService', () => { const mockPlatformPayload = cloneDeep(splitPayloadData3); const reportAndUnspecifiedCategoryParams = { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }; const mockTxn = cloneDeep(txnDataPayload); mockTxn.org_category_id = null; @@ -668,7 +668,7 @@ describe('SplitExpenseService', () => { splitExpenseService .handleSplitMissingFieldsCheck(txnList, fileObject4, txnDataPayload, { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }) .subscribe((res) => { expect(res).toEqual(SplitExpenseMissingFieldsData); @@ -679,7 +679,7 @@ describe('SplitExpenseService', () => { ['fijCeF0G0jTl'], { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, } ); expect(expensesService.splitExpenseCheckMissingFields).toHaveBeenCalledOnceWith(splitPayloadData1); @@ -691,7 +691,7 @@ describe('SplitExpenseService', () => { splitExpenseService .handleSplitMissingFieldsCheck(txnList, fileObject4, txnDataPayload, { reportId: null, - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }) .subscribe((res) => { expect(res).toEqual({}); @@ -708,12 +708,12 @@ describe('SplitExpenseService', () => { spyOn(splitExpenseService, 'handleSplitMissingFieldsCheck').and.returnValue(of(SplitExpenseMissingFieldsData)); const reportAndUnspecifiedCategoryParams = { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }; splitExpenseService .handlePolicyAndMissingFieldsCheck(txnList, fileObject4, txnDataPayload, { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }) .subscribe((res) => { expect(res).toEqual({ @@ -794,12 +794,12 @@ describe('SplitExpenseService', () => { expensesService.splitExpense.and.returnValue(of({ data: txnList })); const reportAndUnspecifiedCategoryParams = { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }; splitExpenseService .splitExpense(txnList, fileObject4, txnDataPayload, { reportId: 'rp0AGAoeQfQX', - unspecifiedCategory: unspecifiedCategory, + unspecifiedCategory, }) .subscribe((res) => { expect(res).toEqual({ data: txnList }); diff --git a/src/app/core/services/transaction.service.spec.ts b/src/app/core/services/transaction.service.spec.ts index ba558a8036..6326dc3e0e 100644 --- a/src/app/core/services/transaction.service.spec.ts +++ b/src/app/core/services/transaction.service.spec.ts @@ -1106,33 +1106,6 @@ describe('TransactionService', () => { }); }); - it('review(): should return transaction response on review', (done) => { - apiService.post.and.returnValue(of(null)); - const transactionId = 'tx3qHxFNgRcZ'; - - transactionService.review(transactionId).subscribe((res) => { - expect(res).toBeNull(); - expect(apiService.post).toHaveBeenCalledOnceWith('/transactions/' + transactionId + '/review'); - done(); - }); - }); - - it('uploadBase64(): should uploadBase64 and return file object response', (done) => { - const transactionID = 'txdzGV1TZEg3'; - const fileName = '000.jpeg'; - const base64Content = 'dummyBase64Value'; - apiService.post.and.returnValue(of(fileObjectData)); - - transactionService.uploadBase64File(transactionID, fileName, base64Content).subscribe((res) => { - expect(res).toEqual(fileObjectData); - expect(apiService.post).toHaveBeenCalledOnceWith('/transactions/' + transactionID + '/upload_b64', { - content: base64Content, - name: fileName, - }); - done(); - }); - }); - it('getTxnAccount(): should get the default txn account', (done) => { orgSettingsService.get.and.returnValue(of(orgSettingsData)); accountsService.getEMyAccounts.and.returnValue(of(accountsData)); diff --git a/src/app/core/services/transaction.service.ts b/src/app/core/services/transaction.service.ts index 3c6a41d7d1..8afe1b45db 100644 --- a/src/app/core/services/transaction.service.ts +++ b/src/app/core/services/transaction.service.ts @@ -350,22 +350,10 @@ export class TransactionService { return this.spenderPlatformV1ApiService.post('/corporate_card_transactions/match', { data: payload }); } - review(txnId: string): Observable { - return this.apiService.post('/transactions/' + txnId + '/review'); - } - getDefaultVehicleType(): Observable { return from(this.storageService.get('vehicle_preference')); } - uploadBase64File(txnId: string, name: string, base64Content: string): Observable { - const data = { - content: base64Content, - name, - }; - return this.apiService.post('/transactions/' + txnId + '/upload_b64', data); - } - unmatchCCCExpense(id: string, expenseId: string): Observable { const payload = { id, diff --git a/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts b/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts index 7f031b0fa8..f0b946afb6 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts @@ -1102,7 +1102,7 @@ export function TestCases4(getTestBed) { ); component.etxn$ = of(transformedExpenseDataWithSubCategory); authService.getEou.and.resolveTo(apiEouRes); - transactionService.review.and.returnValue(of(null)); + transactionService.upsert.and.returnValue(of(transformedExpenseDataWithSubCategory.tx)); expensesService.getExpenseById.and.returnValue(of(platformExpenseDataWithSubCategory)); transactionService.transformExpense.and.returnValue(transformedExpenseDataWithSubCategory); @@ -1222,7 +1222,6 @@ export function TestCases4(getTestBed) { ); component.etxn$ = of(transformedExpenseDataWithReportId2); authService.getEou.and.resolveTo(apiEouRes); - transactionService.review.and.returnValue(of(null)); transactionService.upsert.and.returnValue(of(transformedExpenseDataWithReportId2.tx)); expensesService.getExpenseById.and.returnValue(of(platformExpenseDataWithReportId2)); transactionService.transformExpense.and.returnValue(transformedExpenseDataWithReportId2); diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem-4.page.spec.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem-4.page.spec.ts index 5be7cbb407..bb050da5bd 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem-4.page.spec.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem-4.page.spec.ts @@ -371,7 +371,6 @@ export function TestCases4(getTestBed) { transactionService.transformExpense.and.returnValue(transformedExpenseData); spenderReportsService.addExpenses.and.returnValue(of(undefined)); spenderReportsService.ejectExpenses.and.returnValue(of(undefined)); - transactionService.review.and.returnValue(of(null)); statusService.findLatestComment.and.returnValue(of('comment1')); statusService.post.and.returnValue(of(expenseStatusData)); component.etxn$ = of(transformedExpenseData); @@ -736,7 +735,7 @@ export function TestCases4(getTestBed) { }); }); - it('should throw policyViolations error and save the edited expense and should not call transactionService.review if critical policy is violated', (done) => { + it('should throw policyViolations error and save the edited expense', (done) => { policyService.getCriticalPolicyRules.and.returnValue([]); const mockTxnData = cloneDeep(transformedExpenseData); mockTxnData.tx.policy_amount = 0.00009;