expo-srcpush
Version:
Expo module for Source Push, a service for over-the-air updates in React Native applications.
80 lines (70 loc) • 2.59 kB
text/typescript
import withRnCodepush from '../src/withExpoSrcPush';
import { PluginConfigType } from '../src/pluginConfig';
import { ExpoConfig } from 'expo/config';
describe('withRnCodepush', () => {
it('should apply Android dependencies correctly', () => {
const config: ExpoConfig = {
name: 'test-app',
slug: 'test-app',
};
const props: PluginConfigType = {
android: {
CodePushDeploymentKey: 'test-android-key',
CodePushPublicKey: 'test-public-key',
},
ios: {
CodePushDeploymentKey: 'test-ios-key',
},
};
const updatedConfig = withRnCodepush(config, props);
expect(updatedConfig).toBeDefined();
// Add more assertions based on the expected behavior
});
it('should apply iOS dependencies correctly', () => {
const config: ExpoConfig = {
name: 'test-app',
slug: 'test-app',
};
const props: PluginConfigType = {
android: {
CodePushDeploymentKey: 'test-android-key',
CodePushPublicKey: 'test-public-key',
},
ios: {
CodePushDeploymentKey: 'test-ios-key',
},
};
const updatedConfig = withRnCodepush(config, props);
expect(updatedConfig).toBeDefined();
// Add more assertions based on the expected behavior
});
});
describe('withRnCodepush edge cases', () => {
it('should handle missing android config gracefully', () => {
const config: ExpoConfig = { name: 'test-app', slug: 'test-app' };
const props = {
ios: { CodePushDeploymentKey: 'test-ios-key' },
} as unknown as PluginConfigType;
const updatedConfig = withRnCodepush(config, props);
expect(updatedConfig).toBeDefined();
});
it('should not throw if CodePushPublicKey is missing', () => {
const config: ExpoConfig = { name: 'test-app', slug: 'test-app' };
const props: PluginConfigType = {
android: { CodePushDeploymentKey: 'test-android-key' },
ios: { CodePushDeploymentKey: 'test-ios-key' },
};
const updatedConfig = withRnCodepush(config, props);
expect(updatedConfig).toBeDefined();
});
it('should apply plugins in correct order', () => {
// This test is a smoke test for plugin order, not a deep assertion
const config: ExpoConfig = { name: 'test-app', slug: 'test-app' };
const props: PluginConfigType = {
android: { CodePushDeploymentKey: 'test-android-key', CodePushPublicKey: 'test-public-key' },
ios: { CodePushDeploymentKey: 'test-ios-key' },
};
const updatedConfig = withRnCodepush(config, props);
expect(updatedConfig).toBeDefined();
});
});