Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sdkevents
Browse files Browse the repository at this point in the history
  • Loading branch information
abretonc7s committed Nov 28, 2024
2 parents 33b2967 + 2327799 commit 1645390
Show file tree
Hide file tree
Showing 13 changed files with 605 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,40 @@ exports[`EditGasFee1559 should render correctly 1`] = `
<View>
<HorizontalSelector
onPress={[Function]}
options={[Function]}
options={
[
{
"label": <Text
bold={true}
primary={false}
>
Low
</Text>,
"name": "low",
"topLabel": false,
},
{
"label": <Text
bold={true}
primary={false}
>
Market
</Text>,
"name": "medium",
"topLabel": false,
},
{
"label": <Text
bold={true}
primary={false}
>
Aggressive
</Text>,
"name": "high",
"topLabel": false,
},
]
}
/>
</View>
<View
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/EditGasFee1559/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ const EditGasFee1559 = ({
<HorizontalSelector
selected={selectedOption}
onPress={selectOption}
options={renderOptions}
options={renderOptions()}
/>
</View>
<View style={styles.advancedOptionsContainer}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Mock the networks module before any imports

import React from 'react';
import renderWithProvider, {
DeepPartial,
} from '../../../util/test/renderWithProvider';
import { backgroundState } from '../../../util/test/initial-root-state';
import { RootState } from '../../../reducers';
import AccountPermissions from './AccountPermissions';

const mockedNavigate = jest.fn();
const mockedGoBack = jest.fn();
const mockedTrackEvent = jest.fn();

// Mock navigation
jest.mock('@react-navigation/native', () => {
const actualNav = jest.requireActual('@react-navigation/native');
return {
...actualNav,
useNavigation: () => ({
navigate: mockedNavigate,
goBack: mockedGoBack,
setOptions: jest.fn(),
}),
};
});

// Mock safe area context
jest.mock('react-native-safe-area-context', () => {
const inset = { top: 0, right: 0, bottom: 0, left: 0 };
const frame = { width: 0, height: 0, x: 0, y: 0 };
return {
SafeAreaProvider: jest.fn().mockImplementation(({ children }) => children),
SafeAreaConsumer: jest
.fn()
.mockImplementation(({ children }) => children(inset)),
useSafeAreaInsets: jest.fn().mockImplementation(() => inset),
useSafeAreaFrame: jest.fn().mockImplementation(() => frame),
};
});

// Mock metrics
jest.mock('../../../components/hooks/useMetrics', () => ({
useMetrics: () => ({
trackEvent: mockedTrackEvent,
}),
}));

jest.mock('../../../util/networks/index.js', () => ({
...jest.requireActual('../../../util/networks/index.js'),
isMultichainVersion1Enabled: true,
isChainPermissionsFeatureEnabled: true,
}));

const mockInitialState: DeepPartial<RootState> = {
settings: {},
engine: {
backgroundState: {
...backgroundState,
},
},
};

describe('AccountPermissions with feature flags ON', () => {
it('should render AccountPermissions with multichain and chain permissions enabled', () => {
const { toJSON } = renderWithProvider(
<AccountPermissions
route={{
params: {
hostInfo: { metadata: { origin: 'test' } },
},
}}
/>,
{ state: mockInitialState },
);

expect(toJSON()).toMatchSnapshot('AccountPermissions-FeatureFlagsOn');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jest.mock('../../../components/hooks/useMetrics', () => ({
}),
}));

jest.mock('../../../util/networks/index.js', () => ({
...jest.requireActual('../../../util/networks/index.js'),
isMultichainVersion1Enabled: false,
isChainPermissionsFeatureEnabled: false,
}));

jest.mock('react-native-safe-area-context', () => {
const inset = { top: 0, right: 0, bottom: 0, left: 0 };
const frame = { width: 0, height: 0, x: 0, y: 0 };
Expand Down
Loading

0 comments on commit 1645390

Please sign in to comment.