Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions libraries/expo-iap/example/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,29 @@ describe('Home Component', () => {
});
});

it('should render without crashing', () => {
it('should render without crashing', async () => {
const {getByText} = render(<Home />);
expect(getByText('expo-iap Examples')).toBeDefined();

await waitFor(() => {
expect(ExpoIap.getStorefront).toHaveBeenCalled();
});
});

it('should render the full example menu', () => {
it('should render the full example menu', async () => {
const {getByText} = render(<Home />);

expect(getByText('📱 All Products')).toBeDefined();
expect(getByText('🛒 In-App Purchase Flow')).toBeDefined();
expect(getByText('🔄 Subscription Flow')).toBeDefined();
expect(getByText('📦 Available Purchases')).toBeDefined();
expect(getByText('🎁 Offer Code Redemption')).toBeDefined();
expect(getByText('🌐 Alternative Billing')).toBeDefined();
expect(getByText('📡 Webhook Stream')).toBeDefined();
expect(getByText('All Products')).toBeDefined();
expect(getByText('In-App Purchase Flow')).toBeDefined();
expect(getByText('Subscription Flow')).toBeDefined();
expect(getByText('Available Purchases')).toBeDefined();
expect(getByText('Offer Code Redemption')).toBeDefined();
expect(getByText('Alternative Billing')).toBeDefined();
expect(getByText('Webhook Stream')).toBeDefined();

await waitFor(() => {
expect(ExpoIap.getStorefront).toHaveBeenCalled();
});
});

it('should render on iOS platform', async () => {
Expand All @@ -61,7 +69,7 @@ describe('Home Component', () => {
});
});

it('should render on Android platform', () => {
it('should render on Android platform', async () => {
// Mock Platform.OS to be Android
Object.defineProperty(Platform, 'OS', {
get: jest.fn(() => 'android'),
Expand All @@ -74,7 +82,9 @@ describe('Home Component', () => {
expect(getByText('expo-iap Examples')).toBeDefined();

// getStorefront is called but resolves to empty string on unsupported platforms
expect(ExpoIap.getStorefront).toHaveBeenCalled();
await waitFor(() => {
expect(ExpoIap.getStorefront).toHaveBeenCalled();
});

consoleLog.mockRestore();
});
Expand Down
8 changes: 3 additions & 5 deletions libraries/expo-iap/example/__tests__/layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ jest.mock('expo-router', () => {
Stack.Screen = function MockScreen({name}: {name: string; options?: object}) {
return ReactMock.createElement('View', {testID: name});
};
Stack.Screen.displayName = 'MockScreen';
return {
Stack,
};
});

describe('RootLayout', () => {
it('should render without crashing', () => {
// Just call the function to ensure it executes without errors
const component = RootLayout();
expect(component).toBeDefined();
const {toJSON} = render(<RootLayout />);
expect(toJSON()).toBeDefined();
});

it('should return a valid React element', () => {
const component = RootLayout();
const component = <RootLayout />;
expect(React.isValidElement(component)).toBe(true);
});

Expand Down
2 changes: 1 addition & 1 deletion libraries/expo-iap/example/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default ({config}: ConfigContext): ExpoConfig => {
userInterfaceStyle: 'automatic',
ios: {
...config.ios,
supportsTablet: true,
supportsTablet: false,
bundleIdentifier: 'dev.hyo.martie',
},
android: {
Expand Down
Loading