Skip to content

Commit 3dc760f

Browse files
committed
Move Switch lock icon testID to CONST
1 parent 0318068 commit 3dc760f

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5926,6 +5926,7 @@ const CONST = {
59265926

59275927
DOT_INDICATOR_TEST_ID: 'DotIndicator',
59285928
ANIMATED_COLLAPSIBLE_CONTENT_TEST_ID: 'animated-collapsible-content',
5929+
SWITCH_LOCK_ICON_TEST_ID: 'SwitchLockIcon',
59295930

59305931
HORIZONTAL_SPACER: {
59315932
DEFAULT_BORDER_BOTTOM_WIDTH: 1,

src/components/Switch.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ const OFFSET_X = {
3636
ON: 20,
3737
};
3838

39-
const SWITCH_LOCK_ICON_TEST_ID = 'SwitchLockIcon';
40-
4139
function Switch({isOn, onToggle, accessibilityLabel, disabled, showLockIcon, disabledAction, isNested}: SwitchProps) {
4240
const styles = useThemeStyles();
4341
const {translate} = useLocalize();
@@ -127,7 +125,7 @@ function Switch({isOn, onToggle, accessibilityLabel, disabled, showLockIcon, dis
127125
<Animated.View style={[styles.switchThumb, animatedThumbStyle]}>
128126
{(!!disabled || !!showLockIcon) && (
129127
<Icon
130-
testID={SWITCH_LOCK_ICON_TEST_ID}
128+
testID={CONST.SWITCH_LOCK_ICON_TEST_ID}
131129
src={expensifyIcons.Lock}
132130
fill={isOn ? theme.text : theme.icon}
133131
width={styles.toggleSwitchLockIcon.width}
@@ -141,4 +139,3 @@ function Switch({isOn, onToggle, accessibilityLabel, disabled, showLockIcon, dis
141139
}
142140

143141
export default Switch;
144-
export {SWITCH_LOCK_ICON_TEST_ID};

tests/ui/WorkspaceTravelInvoicingSectionTest.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import ComposeProviders from '@components/ComposeProviders';
66
import {CurrencyListContextProvider} from '@components/CurrencyListContextProvider';
77
import {LocaleContextProvider} from '@components/LocaleContextProvider';
88
import OnyxListItemProvider from '@components/OnyxListItemProvider';
9-
import {SWITCH_LOCK_ICON_TEST_ID} from '@components/Switch';
109
import {payTravelInvoicingSpend} from '@libs/actions/TravelInvoicing';
1110
import {getTravelInvoicingCardSettingsKey} from '@libs/TravelInvoicingUtils';
1211
import WorkspaceTravelInvoicingSection from '@pages/workspace/travel/WorkspaceTravelInvoicingSection';
@@ -527,7 +526,7 @@ describe('WorkspaceTravelInvoicingSection', () => {
527526
await waitForBatchedUpdatesWithAct();
528527

529528
// The lock stays on the toggle since the feature can't be turned off until the balance is paid
530-
expect(screen.getByTestId(SWITCH_LOCK_ICON_TEST_ID, {includeHiddenElements: true})).toBeTruthy();
529+
expect(screen.getByTestId(CONST.SWITCH_LOCK_ICON_TEST_ID, {includeHiddenElements: true})).toBeTruthy();
531530
});
532531

533532
it('does not show the toggle lock icon when the balance is paid', async () => {
@@ -548,7 +547,7 @@ describe('WorkspaceTravelInvoicingSection', () => {
548547
renderWorkspaceTravelInvoicingSection();
549548
await waitForBatchedUpdatesWithAct();
550549

551-
expect(screen.queryByTestId(SWITCH_LOCK_ICON_TEST_ID, {includeHiddenElements: true})).toBeNull();
550+
expect(screen.queryByTestId(CONST.SWITCH_LOCK_ICON_TEST_ID, {includeHiddenElements: true})).toBeNull();
552551
});
553552
});
554553

0 commit comments

Comments
 (0)