Skip to content

Commit

Permalink
tweak plugin context to use ensureInclusion flag
Browse files Browse the repository at this point in the history
  • Loading branch information
arobsn committed Sep 16, 2024
1 parent 029faa8 commit b119f40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions packages/core/src/builder/pluginContext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,26 @@ describe("Plugin context", () => {

it("Should add inputs", () => {
const fromSpy = vi.spyOn(builder, "from");
const configureSelectorMethod = vi.spyOn(builder, "configureSelector");

const newLen = context.addInputs(regularBoxes);

expect(fromSpy).toBeCalledTimes(1);
expect(configureSelectorMethod).toBeCalledTimes(1);
expect(fromSpy).toBeCalledWith(regularBoxes, { ensureInclusion: true });
expect(builder.inputs).toHaveLength(newLen);
expect(builder.inputs).toHaveLength(regularBoxes.length);
});

it("Should add a single input", () => {
const fromMethod = vi.spyOn(builder, "from");
const configureSelectorMethod = vi.spyOn(builder, "configureSelector");
const fromSpy = vi.spyOn(builder, "from");

const inputs = regularBoxes[0];
let newLen = context.addInputs(regularBoxes[0]);
expect(fromMethod).toBeCalledTimes(1);
expect(configureSelectorMethod).toBeCalledTimes(1);
expect(fromSpy).toBeCalledTimes(1);
expect(fromSpy).toBeCalledWith(inputs, { ensureInclusion: true });
expect(builder.inputs).toHaveLength(newLen);
expect(builder.inputs).toHaveLength(1);

newLen = context.addInputs(regularBoxes[1]);
expect(fromMethod).toBeCalledTimes(2);
expect(configureSelectorMethod).toBeCalledTimes(2);
expect(fromSpy).toBeCalledTimes(2);
expect(builder.inputs).toHaveLength(newLen);
expect(builder.inputs).toHaveLength(2);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/builder/pluginContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
OneOrMore,
TokenAmount
} from "@fleet-sdk/common";
import { NotAllowedTokenBurning, type OutputBuilder, type TransactionBuilder } from "..";
import { type OutputBuilder, type TransactionBuilder, NotAllowedTokenBurning } from "..";

export type FleetPluginContext = {
/**
Expand Down

0 comments on commit b119f40

Please sign in to comment.