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 12.0."`
44    );
45  });
46});
47