const { describe, it, expect } = require("@jest/globals");
const briefcase = require("../index.js");
const native = require("../index.node");
const packageJson = require("../package.json");
describe("module exports", () => {
it("exposes stable top-level symbols", () => {
expect(typeof briefcase.init).toBe("function");
expect(typeof briefcase.getVersion).toBe("function");
expect(typeof briefcase.getAuthor).toBe("function");
expect(typeof briefcase.SimpleInput).toBe("function");
expect(typeof briefcase.SimpleOutput).toBe("function");
expect(typeof briefcase.SimpleDecisionSnapshot).toBe("function");
});
it("reports package-aligned version", () => {
expect(briefcase.getVersion()).toBe(packageJson.version);
});
it("loads native module through index.js bridge", () => {
expect(typeof native.getVersion).toBe("function");
expect(briefcase.getVersion()).toBe(native.getVersion());
});
});
describe("SimpleInput and SimpleOutput", () => {
it("constructs inputs/outputs with expected getters", () => {
const input = new briefcase.SimpleInput("prompt", "hello", "string");
const output = new briefcase.SimpleOutput("response", "hi", "string");
output.withConfidence(0.91);
expect(input.name).toBe("prompt");
expect(input.value).toBe('"hello"');
expect(input.dataType).toBe("string");
expect(output.name).toBe("response");
expect(output.value).toBe('"hi"');
expect(output.confidence).toBe(0.91);
});
});
describe("SimpleDecisionSnapshot", () => {
it("builds and serializes a snapshot", () => {
const decision = new briefcase.SimpleDecisionSnapshot("classify");
decision.addInput(new briefcase.SimpleInput("prompt", "hello", "string"));
decision.addOutput(new briefcase.SimpleOutput("response", "hi", "string"));
decision.withExecutionTime(12.3);
decision.addTag("env", "test");
expect(decision.functionName).toBe("classify");
expect(decision.executionTimeMs).toBe(12.3);
const asJson = JSON.parse(decision.toJson());
expect(asJson.function_name).toBe("classify");
expect(asJson.inputs).toHaveLength(1);
expect(asJson.outputs).toHaveLength(1);
expect(asJson.tags.env).toBe("test");
expect(asJson.metadata.sdk_version).toBe(packageJson.version);
});
});