import React from 'react';
import {render} from '@testing-library/react-native';
import {GlobalContextProvider} from './GlobalContextProvider';
import {Text} from 'react-native';
// Mock xstate
jest.mock('@xstate/react', () => ({
useInterpret: jest.fn(() => ({
subscribe: jest.fn(),
})),
}));
// Mock appMachine
jest.mock('../machines/app', () => ({
appMachine: {},
}));
// Mock GlobalContext
jest.mock('../shared/GlobalContext', () => ({
GlobalContext: {
Provider: ({children}: {children: React.ReactNode}) => <>{children}>,
},
}));
// Mock commonUtil
jest.mock('../shared/commonUtil', () => ({
logState: jest.fn(),
}));
describe('GlobalContextProvider Component', () => {
it('should match snapshot with children', () => {
const {toJSON} = render(
Test Child
,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with multiple children', () => {
const {toJSON} = render(
Child 1
Child 2
,
);
expect(toJSON()).toMatchSnapshot();
});
});