# tests/core/generators/agenda.generator.test.ts

> 26 lines of code and 0 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tests-core-generators-agenda-generator-test-ts
Source text: https://banes-lab.com/assets/sources/source.078ad99cf0a44664da64b06027e8237af674d64b58ed0f70bbaad1eaf92de512.generated.txt

## Source

```typescript
import { describe, it } from "node:test";
import { dirname, join, resolve } from "node:path";
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { AGENDA } from "../../../tools/core/constants/blocking.constants.ts";
import assert from "node:assert/strict";
import { tmpdir } from "node:os";
import { writeAgendaIfUnmoved } from "../../../tools/core/generators/agenda.generator.ts";

const WITNESSED = "# Agenda\n- planned invariant\n";

const seeded = function seeded(): string {
    const root = mkdtempSync(join(tmpdir(), "coordination-agenda-"));
    mkdirSync(dirname(resolve(root, AGENDA)), { recursive: true });
    writeFileSync(resolve(root, AGENDA), WITNESSED);
    return root;
};

describe("writeAgendaIfUnmoved", () => {
    it("writes the rendered agenda when the file still holds what was read", () => {
        const root = seeded();
        assert.equal(writeAgendaIfUnmoved(root, WITNESSED, "# Agenda\n- rendered\n"), true);
        assert.equal(readFileSync(resolve(root, AGENDA), "utf8"), "# Agenda\n- rendered\n");
    });

    it("refuses and leaves the file alone when it moved since it was read", () => {
        const root = seeded();
        assert.equal(writeAgendaIfUnmoved(root, "an older read", "# Agenda\n- rendered\n"), false);
        assert.equal(readFileSync(resolve(root, AGENDA), "utf8"), WITNESSED);
    });
});
```
