-
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.
Merge pull request #53816 from truph01/fix/53659
fix: Hmm it's not here in RHP is displayed after deleting a workspace
- Loading branch information
Showing
1 changed file
with
48 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,17 +1,22 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import Onyx from 'react-native-onyx'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import DateUtils from '@libs/DateUtils'; | ||
import {getActivePolicies, getRateDisplayValue, getSubmitToAccountID, getUnitRateValue} from '@libs/PolicyUtils'; | ||
import {getActivePolicies, getRateDisplayValue, getSubmitToAccountID, getUnitRateValue, shouldShowPolicy} from '@libs/PolicyUtils'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {PersonalDetailsList, Policy, PolicyEmployeeList, Report, Transaction} from '@src/types/onyx'; | ||
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 * as TestHelper from '../utils/TestHelper'; | ||
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; | ||
import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; | ||
import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; | ||
|
||
const CARLOS_EMAIL = '[email protected]'; | ||
const CARLOS_ACCOUNT_ID = 1; | ||
function toLocaleDigitMock(dot: string): string { | ||
return dot; | ||
} | ||
|
@@ -427,4 +432,46 @@ describe('PolicyUtils', () => { | |
}); | ||
}); | ||
}); | ||
describe('shouldShowPolicy', () => { | ||
beforeAll(() => { | ||
Onyx.init({ | ||
keys: ONYXKEYS, | ||
initialKeyStates: { | ||
[ONYXKEYS.SESSION]: {accountID: CARLOS_ACCOUNT_ID, email: CARLOS_EMAIL}, | ||
}, | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
global.fetch = TestHelper.getGlobalFetchMock(); | ||
return Onyx.clear().then(waitForBatchedUpdates); | ||
}); | ||
it('should return false', () => { | ||
// Given an archived paid policy. | ||
const policy = { | ||
...createRandomPolicy(1, CONST.POLICY.TYPE.CORPORATE), | ||
role: '', | ||
}; | ||
const result = shouldShowPolicy(policy as OnyxEntry<Policy>, false, CARLOS_EMAIL); | ||
// The result should be false since it is an archived paid policy. | ||
expect(result).toBe(false); | ||
}); | ||
it('should return true', () => { | ||
// Given a paid policy. | ||
const policy = {...createRandomPolicy(1, CONST.POLICY.TYPE.CORPORATE), pendingAction: null}; | ||
const result = shouldShowPolicy(policy as OnyxEntry<Policy>, false, CARLOS_EMAIL); | ||
// The result should be true, since it is an active paid policy. | ||
expect(result).toBe(true); | ||
}); | ||
it('should returnfalse', () => { | ||
// Given a control workspace which is pending delete. | ||
const policy = { | ||
...createRandomPolicy(1, CONST.POLICY.TYPE.CORPORATE), | ||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, | ||
}; | ||
const result = shouldShowPolicy(policy as OnyxEntry<Policy>, false, CARLOS_EMAIL); | ||
// The result should be false since it is a policy which is pending deletion. | ||
expect(result).toEqual(false); | ||
}); | ||
}); | ||
}); |