Skip to content

Commit

Permalink
chore: cleanup unused methods (#3198)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunaj5 authored Sep 10, 2024
1 parent 7a27205 commit 0b50873
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 57 deletions.
28 changes: 14 additions & 14 deletions src/app/core/services/split-expense.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe('SplitExpenseService', () => {

beforeEach(() => {
const transactionServiceSpy = jasmine.createSpyObj('TransactionService', [
'uploadBase64File',
'checkPolicy',
'upsert',
'transformRawExpense',
Expand Down Expand Up @@ -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;
Expand All @@ -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);
});
});
Expand Down Expand Up @@ -503,7 +503,7 @@ describe('SplitExpenseService', () => {
splitExpenseService
.handleSplitPolicyCheck(txnList, fileObject4, txnDataPayload, {
reportId: null,
unspecifiedCategory: unspecifiedCategory,
unspecifiedCategory,
})
.subscribe((res) => {
expect(res).toEqual(splitPolicyExp1);
Expand All @@ -514,7 +514,7 @@ describe('SplitExpenseService', () => {
['fijCeF0G0jTl'],
{
reportId: null,
unspecifiedCategory: unspecifiedCategory,
unspecifiedCategory,
}
);
expect(expensesService.splitExpenseCheckPolicies).toHaveBeenCalledOnceWith(splitPayloadData1);
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('SplitExpenseService', () => {
const mockPlatformPayload = cloneDeep(splitPayloadData2);
const reportAndUnspecifiedCategoryParams = {
reportId: 'rp0AGAoeQfQX',
unspecifiedCategory: unspecifiedCategory,
unspecifiedCategory,
};
const res = splitExpenseService.transformSplitTo(
mockSplitTxn,
Expand All @@ -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;
Expand Down Expand Up @@ -668,7 +668,7 @@ describe('SplitExpenseService', () => {
splitExpenseService
.handleSplitMissingFieldsCheck(txnList, fileObject4, txnDataPayload, {
reportId: 'rp0AGAoeQfQX',
unspecifiedCategory: unspecifiedCategory,
unspecifiedCategory,
})
.subscribe((res) => {
expect(res).toEqual(SplitExpenseMissingFieldsData);
Expand All @@ -679,7 +679,7 @@ describe('SplitExpenseService', () => {
['fijCeF0G0jTl'],
{
reportId: 'rp0AGAoeQfQX',
unspecifiedCategory: unspecifiedCategory,
unspecifiedCategory,
}
);
expect(expensesService.splitExpenseCheckMissingFields).toHaveBeenCalledOnceWith(splitPayloadData1);
Expand All @@ -691,7 +691,7 @@ describe('SplitExpenseService', () => {
splitExpenseService
.handleSplitMissingFieldsCheck(txnList, fileObject4, txnDataPayload, {
reportId: null,
unspecifiedCategory: unspecifiedCategory,
unspecifiedCategory,
})
.subscribe((res) => {
expect(res).toEqual({});
Expand All @@ -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({
Expand Down Expand Up @@ -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 });
Expand Down
27 changes: 0 additions & 27 deletions src/app/core/services/transaction.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 0 additions & 12 deletions src/app/core/services/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,22 +350,10 @@ export class TransactionService {
return this.spenderPlatformV1ApiService.post('/corporate_card_transactions/match', { data: payload });
}

review(txnId: string): Observable<null> {
return this.apiService.post('/transactions/' + txnId + '/review');
}

getDefaultVehicleType(): Observable<string> {
return from(this.storageService.get<string>('vehicle_preference'));
}

uploadBase64File(txnId: string, name: string, base64Content: string): Observable<FileObject> {
const data = {
content: base64Content,
name,
};
return this.apiService.post('/transactions/' + txnId + '/upload_b64', data);
}

unmatchCCCExpense(id: string, expenseId: string): Observable<CorporateCardTransactionRes> {
const payload = {
id,
Expand Down
3 changes: 1 addition & 2 deletions src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0b50873

Please sign in to comment.