# test.govlab/docs/core/analyzers/orchestration.analyzer.test.ts

> 32 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-docs-core-analyzers-orchestration-analyzer-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/docs/core/analyzers/orchestration.analyzer.test.ts.txt

Listed in [test.govlab/docs/core/analyzers](https://banes-lab.com/api/source/testing/test.govlab/docs/core/analyzers.md), after [test.govlab/docs/core/analyzers/markdown.analyzer.test.ts](https://banes-lab.com/source/testing/test.govlab/docs/core/analyzers/markdown.analyzer.test.ts.md) and before [test.govlab/docs/core/analyzers/package.analyzer.test.ts](https://banes-lab.com/source/testing/test.govlab/docs/core/analyzers/package.analyzer.test.ts.md).

## Contained in

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

## Source

```typescript
import { afterAll, describe, expect, it } from "vitest";
import { detectProtocol } from "@govlab/docs/core/analyzers/orchestration.analyzer.ts";
import { programFor } from "./program.fixture.ts";

const fixture = programFor({
    "pay.ts": [
        "declare const gateway: { charge(): Promise<void> };",
        "declare const vault: { store(): Promise<void> };",
        "export async function processPayment(): Promise<void> {",
        "    await gateway.charge();",
        "    await vault.store();",
        "    await gateway.charge();",
        "}",
        "export async function thin(): Promise<void> {",
        "    await vault.store();",
        "}",
    ].join("\n"),
});

afterAll(() => {
    fixture.dispose();
});

describe("detectProtocol", () => {
    it("picks the function with the most distinct awaited collaborator calls", () => {
        expect(detectProtocol(fixture.analysis)).toStrictEqual({
            messages: [
                { async: true, text: "charge", to: "gateway" },
                { async: true, text: "store", to: "vault" },
            ],
            participants: ["gateway", "vault"],
            self: "processPayment",
        });
    });
});
```
