# test.deploy/core/reporters/nginx.reporter.test.ts

> 44 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-deploy-core-reporters-nginx-reporter-test-ts
Source text: https://banes-lab.com/source/testing/test.deploy/core/reporters/nginx.reporter.test.ts.txt

Listed in [test.deploy/core/reporters](https://banes-lab.com/api/source/testing/test.deploy/core/reporters.md), after [test.deploy/core/reporters/journal.reporter.test.ts](https://banes-lab.com/source/testing/test.deploy/core/reporters/journal.reporter.test.ts.md) and before [test.deploy/core/reporters/notification.reporter.test.ts](https://banes-lab.com/source/testing/test.deploy/core/reporters/notification.reporter.test.ts.md).

## Contained in

- [test.deploy/core/reporters](https://banes-lab.com/anatomy/testing/folder-testing-test-deploy-core-reporters.md)

## Source

```typescript
import {
    PULL_FAILURE_TITLE,
    PULL_SUCCESS_TITLE,
    PUSH_FAILURE_TITLE,
    PUSH_SUCCESS_TITLE,
} from "@banes-lab/deploy/configuration/strings/notification.strings.ts";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
    reportPull,
    reportPullFailure,
    reportPush,
    reportPushFailure,
} from "@banes-lab/deploy/core/reporters/nginx.reporter.ts";
import { stubFetch, titleOf } from "./webhook.fixture.ts";
import type { Span } from "@banes-lab/deploy/types/deployment.types.ts";
import { fakeJournal } from "../steps/shell.fixture.ts";
import { localSiteConfig } from "@banes-lab/deploy/core/steps/nginx.step.ts";

const SPAN: Span = { finishedAt: 2, startedAt: 1 };
const URL = "https://hooks.example.test/1";

describe("nginx reporter", () => {
    afterEach(() => {
        vi.unstubAllGlobals();
    });

    it("reportPull posts the pull success title", async () => {
        const fetchMock = stubFetch();
        await reportPull(fakeJournal(), URL, SPAN, "local.conf");
        expect(titleOf(fetchMock)).toBe(PULL_SUCCESS_TITLE);
    });

    it("reportPullFailure posts the pull failure title", async () => {
        const fetchMock = stubFetch();
        await reportPullFailure(fakeJournal(), URL, SPAN, "boom");
        expect(titleOf(fetchMock)).toBe(PULL_FAILURE_TITLE);
    });

    it("reportPush attaches the local config and posts the push success title", async () => {
        const fetchMock = stubFetch();
        await reportPush(fakeJournal(), URL, SPAN, "remote-backup", localSiteConfig());
        expect(titleOf(fetchMock)).toBe(PUSH_SUCCESS_TITLE);
    });

    it("reportPushFailure posts the push failure title", async () => {
        const fetchMock = stubFetch();
        await reportPushFailure(fakeJournal(), URL, SPAN, "", "boom");
        expect(titleOf(fetchMock)).toBe(PUSH_FAILURE_TITLE);
    });
});
```
