-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c05791
commit 0e7beb3
Showing
1 changed file
with
22 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ import createCollection from '../utils/collections/createCollection'; | |
import createRandomPolicy from '../utils/collections/policies'; | ||
import createRandomReport from '../utils/collections/reports'; | ||
import createRandomTransaction from '../utils/collections/transaction'; | ||
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; | ||
import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; | ||
Check failure on line 11 in tests/unit/PolicyUtilsTest.ts GitHub Actions / Changed files ESLint check
|
||
import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; | ||
Check failure on line 12 in tests/unit/PolicyUtilsTest.ts GitHub Actions / Changed files ESLint check
|
||
|
||
function toLocaleDigitMock(dot: string): string { | ||
return dot; | ||
|
@@ -230,11 +231,12 @@ describe('PolicyUtils', () => { | |
|
||
describe('getSubmitToAccountID', () => { | ||
beforeEach(() => { | ||
wrapOnyxWithWaitForBatchedUpdates(Onyx); | ||
Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, personalDetails); | ||
return waitForBatchedUpdates(); | ||
}); | ||
afterEach(() => { | ||
Onyx.clear(); | ||
afterEach(async () => { | ||
await Onyx.clear(); | ||
await waitForBatchedUpdatesWithAct(); | ||
}); | ||
describe('Has no rule approver', () => { | ||
it('should return the policy approver/owner if the policy use the optional or basic workflow', () => { | ||
|
@@ -270,14 +272,15 @@ describe('PolicyUtils', () => { | |
}); | ||
}); | ||
describe('Has category/tag approver', () => { | ||
it('should return the first category approver if has any transaction category match with category approver rule', () => { | ||
it('should return the first category approver if has any transaction category match with category approver rule', async() => { | ||
Check failure on line 275 in tests/unit/PolicyUtilsTest.ts GitHub Actions / Changed files ESLint check
|
||
const policy: Policy = { | ||
...createRandomPolicy(0), | ||
approver: '[email protected]', | ||
owner: '[email protected]', | ||
type: 'team', | ||
employeeList, | ||
rules, | ||
approvalMode: CONST.POLICY.APPROVAL_MODE.ADVANCED, | ||
}; | ||
const expenseReport: Report = { | ||
...createRandomReport(0), | ||
|
@@ -294,21 +297,21 @@ describe('PolicyUtils', () => { | |
category: '', | ||
reportID: expenseReport.reportID, | ||
}; | ||
Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
await Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
[transaction1.transactionID]: transaction1, | ||
[transaction2.transactionID]: transaction2, | ||
}).then(() => { | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(categoryapprover1AccountID); | ||
}); | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(categoryapprover1AccountID); | ||
}); | ||
it('should return the category approver of the first transaction sorted by created if we have many transaction categories match with the category approver rule', () => { | ||
it('should return the category approver of the first transaction sorted by created if we have many transaction categories match with the category approver rule', async() => { | ||
Check failure on line 306 in tests/unit/PolicyUtilsTest.ts GitHub Actions / Changed files ESLint check
|
||
const policy: Policy = { | ||
...createRandomPolicy(0), | ||
approver: '[email protected]', | ||
owner: '[email protected]', | ||
type: 'team', | ||
employeeList, | ||
rules, | ||
approvalMode: CONST.POLICY.APPROVAL_MODE.ADVANCED, | ||
}; | ||
const expenseReport: Report = { | ||
...createRandomReport(0), | ||
|
@@ -327,22 +330,22 @@ describe('PolicyUtils', () => { | |
created: '2', | ||
reportID: expenseReport.reportID, | ||
}; | ||
Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
await Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
[transaction1.transactionID]: transaction1, | ||
[transaction2.transactionID]: transaction2, | ||
}).then(() => { | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(categoryapprover2AccountID); | ||
}); | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(categoryapprover2AccountID); | ||
}); | ||
describe('Has no transaction match with the category approver rule', () => { | ||
it('should return the first tag approver if has any transaction tag match with with the tag approver rule ', () => { | ||
it('should return the first tag approver if has any transaction tag match with with the tag approver rule ', async() => { | ||
Check failure on line 340 in tests/unit/PolicyUtilsTest.ts GitHub Actions / Changed files ESLint check
|
||
const policy: Policy = { | ||
...createRandomPolicy(0), | ||
approver: '[email protected]', | ||
owner: '[email protected]', | ||
type: 'team', | ||
employeeList, | ||
rules, | ||
approvalMode: CONST.POLICY.APPROVAL_MODE.ADVANCED, | ||
}; | ||
const expenseReport: Report = { | ||
...createRandomReport(0), | ||
|
@@ -363,21 +366,21 @@ describe('PolicyUtils', () => { | |
created: '2', | ||
reportID: expenseReport.reportID, | ||
}; | ||
Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
await Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
[transaction1.transactionID]: transaction1, | ||
[transaction2.transactionID]: transaction2, | ||
}).then(() => { | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(tagapprover1AccountID); | ||
}); | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(tagapprover1AccountID); | ||
}); | ||
it('should return the tag approver of the first transaction sorted by created if we have many transaction tags match with the tag approver rule', () => { | ||
it('should return the tag approver of the first transaction sorted by created if we have many transaction tags match with the tag approver rule', async() => { | ||
Check failure on line 375 in tests/unit/PolicyUtilsTest.ts GitHub Actions / Changed files ESLint check
|
||
const policy: Policy = { | ||
...createRandomPolicy(0), | ||
approver: '[email protected]', | ||
owner: '[email protected]', | ||
type: 'team', | ||
employeeList, | ||
rules, | ||
approvalMode: CONST.POLICY.APPROVAL_MODE.ADVANCED, | ||
}; | ||
const expenseReport: Report = { | ||
...createRandomReport(0), | ||
|
@@ -398,12 +401,11 @@ describe('PolicyUtils', () => { | |
created: '2', | ||
reportID: expenseReport.reportID, | ||
}; | ||
Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
await Onyx.set(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
[transaction1.transactionID]: transaction1, | ||
[transaction2.transactionID]: transaction2, | ||
}).then(() => { | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(tagapprover2AccountID); | ||
}); | ||
expect(PolicyUtils.getSubmitToAccountID(policy, expenseReport)).toBe(tagapprover2AccountID); | ||
}); | ||
}); | ||
}); | ||
|