Skip to content

Commit

Permalink
fix: Split jest config files and change args for `randomAstStructInst…
Browse files Browse the repository at this point in the history
…ance`
  • Loading branch information
xpyctumo committed Dec 26, 2024
1 parent 88786b8 commit de192e5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ src/func/funcfiftlib.js
**/grammar.ohm*.ts
**/grammar.ohm*.js
jest.setup.js
jest.globalSetup.js
jest.teardown.js
/docs
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
testEnvironment: "node",
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
maxWorkers: "50%",
globalSetup: "./jest.setup.js",
globalSetup: "./jest.globalSetup.js",
setupFiles: ["./jest.setup.js"],
globalTeardown: "./jest.teardown.js",
snapshotSerializers: ["@tact-lang/ton-jest/serializers"],
Expand Down
8 changes: 8 additions & 0 deletions jest.globalSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const coverage = require("@tact-lang/coverage");

module.exports = async () => {
if (process.env.COVERAGE === "true") {
coverage.beginCoverage();
}
};
8 changes: 0 additions & 8 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const coverage = require("@tact-lang/coverage");
const fc = require("fast-check");

module.exports = async () => {
if (process.env.COVERAGE === "true") {
coverage.beginCoverage();
}
};

function sanitizeObject(
obj,
options = {
Expand Down
8 changes: 7 additions & 1 deletion src/test/prettyPrint/expressions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
randomAstNull,
randomAstStaticCall,
randomAstStructInstance,
randomAstStructFieldInitializer,
} from "../utils/expression/randomAst";

describe("Pretty Print Expressions", () => {
Expand All @@ -28,7 +29,12 @@ describe("Pretty Print Expressions", () => {
["AstNull", randomAstNull()],
["AstInitOf", randomAstInitOf(expression())],
["AstStaticCall", randomAstStaticCall(expression())],
["AstStructInstance", randomAstStructInstance(expression())],
[
"AstStructInstance",
randomAstStructInstance(
randomAstStructFieldInitializer(expression()),
),
],
];

cases.forEach(([caseName, astGenerator]) => {
Expand Down
6 changes: 3 additions & 3 deletions src/test/utils/expression/randomAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export function randomAstStaticCall(
);
}

function randomAstStructFieldInitializer(
export function randomAstStructFieldInitializer(
expression: fc.Arbitrary<AstExpression>,
): fc.Arbitrary<AstStructFieldInitializer> {
return dummyAstNode(
Expand All @@ -173,13 +173,13 @@ function randomAstStructFieldInitializer(
}

export function randomAstStructInstance(
expression: fc.Arbitrary<AstExpression>,
structFieldInitializer: fc.Arbitrary<AstStructFieldInitializer>,
): fc.Arbitrary<AstStructInstance> {
return dummyAstNode(
fc.record({
kind: fc.constant("struct_instance"),
type: randomAstId(),
args: fc.array(randomAstStructFieldInitializer(expression)),
args: fc.array(structFieldInitializer),
}),
);
}
Expand Down

0 comments on commit de192e5

Please sign in to comment.