Skip to content

Commit

Permalink
Add test for custom manifest file detection
Browse files Browse the repository at this point in the history
  • Loading branch information
BowTiedRadone committed Feb 3, 2025
1 parent f21e941 commit 7ab7118
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions app.tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { red } from "ansicolor";
import { getManifestFileName, main } from "./app";
import { version } from "./package.json";
import { cpSync, mkdtempSync, rmdirSync, writeFileSync } from "fs";
import { join, resolve } from "path";
import { tmpdir } from "os";

describe("Command-line arguments handling", () => {
const initialArgv = process.argv;
Expand Down Expand Up @@ -379,4 +382,44 @@ describe("Custom manifest detection", () => {
// Assert
expect(actual).toBe("Clarinet.toml");
});

it("returns the custom manifest file name for a project that has one", () => {
// Setup
const exampleProject = "example";
const tempDir = mkdtempSync(join(tmpdir(), "simnet-test-"));

// Create a custom manifest file complying with the Rendezvous convention:
// `Clarinet-<target-contract-name>.toml`.
const expected = "Clarinet-counter.toml";

cpSync(exampleProject, tempDir, { recursive: true });

writeFileSync(
resolve(tempDir, expected),
`
[project]
name = "example"
telemetry = false
cache_dir = "./.cache"
[contracts.counter]
path = "contracts/counter.clar"
clarity_version = 3
epoch = 3.0
[repl.analysis]
passes = ["check_checker"]
check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
`
);

// Exercise
const actual = getManifestFileName(tempDir, "counter");

// Verify
expect(actual).toBe(expected);

// Teardown
rmdirSync(tempDir, { recursive: true });
});
});

0 comments on commit 7ab7118

Please sign in to comment.