# test.govlab/argv/core/resolvers/invocation.resolver.test.ts

> 26 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-argv-core-resolvers-invocation-resolver-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/argv/core/resolvers/invocation.resolver.test.ts.txt

Listed in [test.govlab/argv/core/resolvers](https://banes-lab.com/api/source/testing/test.govlab/argv/core/resolvers.md).

## Contained in

- [test.govlab/argv/core/resolvers](https://banes-lab.com/anatomy/testing/folder-testing-test-govlab-argv-core-resolvers.md)

## Source

```typescript
import { ARGV_OFFSET, EXIT_CLEAN, EXIT_REFUSED } from "@govlab/argv/configuration/constants/invocation.constants.ts";
import { ArgvRefusedError, argvOf, resolveArgv } from "@govlab/argv";
import { HELP_UNANSWERED, refusedLine } from "@govlab/argv/configuration/strings/invocation.strings.ts";
import { describe, expect, it } from "vitest";
import { SPEC } from "../converters/invocation.fixture.ts";

describe("argvOf", () => {
    it("throws the refusal instead of exiting", () => {
        expect(() => argvOf(SPEC, ["in", "--bogus"])).toThrow(ArgvRefusedError);
    });

    it("refuses a help request, which a programmatic caller cannot answer", () => {
        expect(() => argvOf(SPEC, ["--help"])).toThrow(HELP_UNANSWERED);
    });
});

describe("resolveArgv", () => {
    it("returns the parsed view for an explicit word list", () => {
        expect(resolveArgv(SPEC, ["in"]).positionals).toStrictEqual(["in"]);
    });

    it("skips the runtime and script words, and exits clean on help and non-zero on refusal", () => {
        expect(ARGV_OFFSET).toBe(2);
        expect(EXIT_CLEAN).toBe(0);
        expect(EXIT_REFUSED).not.toBe(EXIT_CLEAN);
    });

    it("prints the reason ahead of the usage on refusal", () => {
        expect(refusedLine("why", "usage")).toContain("why\n\nusage");
    });
});
```
