1import { validateConfig } from '../pluginConfig'; 2 3describe(validateConfig, () => { 4 it('should throw error from invalid config type', () => { 5 expect(() => { 6 validateConfig(undefined); 7 }).toThrow(); 8 expect(() => { 9 validateConfig(null); 10 }).toThrow(); 11 expect(() => { 12 validateConfig('foo'); 13 }).toThrow(); 14 expect(() => { 15 validateConfig({ android: { compileSdkVersion: 'aString' } }); 16 }).toThrow(); 17 }); 18 19 it('should throw error from unsupported android versions', () => { 20 expect(() => 21 validateConfig({ android: { minSdkVersion: 14 } }) 22 ).toThrowErrorMatchingInlineSnapshot( 23 `"\`android.minSdkVersion\` needs to be at least version 21."` 24 ); 25 expect(() => 26 validateConfig({ android: { compileSdkVersion: 14 } }) 27 ).toThrowErrorMatchingInlineSnapshot( 28 `"\`android.compileSdkVersion\` needs to be at least version 31."` 29 ); 30 expect(() => 31 validateConfig({ android: { targetSdkVersion: 14 } }) 32 ).toThrowErrorMatchingInlineSnapshot( 33 `"\`android.targetSdkVersion\` needs to be at least version 31."` 34 ); 35 expect(() => 36 validateConfig({ android: { kotlinVersion: '1.3.0' } }) 37 ).toThrowErrorMatchingInlineSnapshot( 38 `"\`android.kotlinVersion\` needs to be at least version 1.6.10."` 39 ); 40 expect(() => 41 validateConfig({ ios: { deploymentTarget: '9.0' } }) 42 ).toThrowErrorMatchingInlineSnapshot( 43 `"\`ios.deploymentTarget\` needs to be at least version 13.0."` 44 ); 45 }); 46 47 it('should not allow ios.flipper and ios.useFrameworks at the same time', () => { 48 expect(() => 49 validateConfig({ ios: { flipper: true, useFrameworks: 'static' } }) 50 ).toThrowErrorMatchingInlineSnapshot( 51 `"\`ios.flipper\` cannot be enabled when \`ios.useFrameworks\` is set."` 52 ); 53 }); 54 55 it('should use `enableShrinkResourcesInReleaseBuilds` with `enableProguardInReleaseBuilds`', () => { 56 expect(() => 57 validateConfig({ android: { enableShrinkResourcesInReleaseBuilds: true } }) 58 ).toThrow(); 59 60 expect(() => 61 validateConfig({ 62 android: { 63 enableShrinkResourcesInReleaseBuilds: true, 64 enableProguardInReleaseBuilds: true, 65 }, 66 }) 67 ).not.toThrow(); 68 69 expect(() => 70 validateConfig({ 71 android: { 72 enableShrinkResourcesInReleaseBuilds: true, 73 enableProguardInReleaseBuilds: false, 74 }, 75 }) 76 ).toThrow(); 77 }); 78}); 79