1import { AndroidConfig, AndroidManifest } from '@expo/config-plugins';
2
3import { setGeneratedAndroidScheme } from '../withGeneratedAndroidScheme';
4
5describe(setGeneratedAndroidScheme, () => {
6  it(`prevents adding duplicates`, () => {
7    let androidManifest: AndroidManifest = {
8      manifest: {
9        application: [
10          {
11            activity: [
12              {
13                $: {
14                  'android:name': '.MainActivity',
15                  'android:launchMode': 'singleTask',
16                },
17                'intent-filter': [
18                  {
19                    action: [
20                      {
21                        $: {
22                          'android:name': 'android.intent.action.VIEW',
23                        },
24                      },
25                    ],
26                    category: [
27                      {
28                        $: {
29                          'android:name': 'android.intent.category.DEFAULT',
30                        },
31                      },
32                      {
33                        $: {
34                          'android:name': 'android.intent.category.BROWSABLE',
35                        },
36                      },
37                    ],
38                    data: [],
39                  },
40                ],
41              },
42            ],
43            $: {
44              'android:name': '.MainApplication',
45            },
46          },
47        ],
48        $: {
49          'xmlns:android': 'http://schemas.android.com/apk/res/android',
50          package: 'com.placeholder.appid',
51        },
52      },
53    };
54    const config = { slug: 'cello' };
55
56    for (let i = 0; i < 2; i++) {
57      androidManifest = setGeneratedAndroidScheme(config, androidManifest);
58
59      expect(AndroidConfig.Scheme.getSchemesFromManifest(androidManifest)).toStrictEqual([
60        'exp+cello',
61      ]);
62    }
63  });
64});
65