1import { resolveArgsAsync } from '../resolveOptions';
2
3describe(resolveArgsAsync, () => {
4  it(`asserts invalid flags`, async () => {
5    await expect(resolveArgsAsync(['-g', '--bacon'])).rejects.toThrow(/Unexpected: -g, --bacon/);
6  });
7  it(`prevents bad combos`, async () => {
8    await expect(resolveArgsAsync(['--npm', '--yarn'])).rejects.toThrow(
9      /Specify at most one of: --npm, --pnpm, --yarn/
10    );
11    await expect(resolveArgsAsync(['--npm', '--pnpm', '--yarn'])).rejects.toThrow(
12      /Specify at most one of: --npm, --pnpm, --yarn/
13    );
14  });
15  it(`allows known values`, async () => {
16    const result = await resolveArgsAsync([
17      'bacon',
18      '@evan/bacon',
19      '--yarn',
20      'another@foobar',
21      'file:../thing',
22      '--',
23      '--npm',
24      '-g',
25      'not-a-plugin',
26    ]);
27    expect(result).toEqual({
28      variadic: ['bacon', '@evan/bacon', 'another@foobar', 'file:../thing'],
29      options: {
30        npm: false,
31        yarn: true,
32        check: false,
33        pnpm: false,
34        bun: false,
35        fix: false,
36      },
37      extras: ['--npm', '-g', 'not-a-plugin'],
38    });
39  });
40  it(`allows known values without correct chaining`, async () => {
41    const result = await resolveArgsAsync(['expo', '--npm', '--check', '--']);
42    expect(result).toEqual({
43      variadic: ['expo'],
44      options: {
45        npm: true,
46        yarn: false,
47        check: true,
48        pnpm: false,
49        bun: false,
50        fix: false,
51      },
52      extras: [],
53    });
54  });
55});
56