Skip to content

Commit

Permalink
gen2e-inteepreter: tests fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rhighs committed Jun 11, 2024
1 parent 3e6fc1b commit 6c25d72
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions packages/gen2e-interpreter/tests/unit/ast/pw-compile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,28 @@ describe("pwCompile", () => {
});

test('should replace gen("<task>", { page, test }) with static Playwright expressions', () => {
const sourceCode = `
test('example test', async () => {
await gen('task 1', { page, test });
});
`;
const sourceCode = `\
test('example test', async () => {
await gen('task 1', { page, test });
});`;

const ident = staticStore.makeIdent("example test", "task 1");
const staticCode = "async () => { /* static code */ }";
staticStore.makeStatic({
ident,
expression: "async () => { /* static code */ }",
expression: staticCode,
});

const result = pwCompile(sourceCode, staticStore);

expect(result).toContain("async () => { /* static code */ }");
expect(result).toContain(staticCode);
expect(result).toContain("gen2e:compiled-output - example test");
});

test("should throw an error for undefined or empty expression", () => {
const sourceCode = `
test('example test', async () => {
await gen('task 1', { page, test });
});
`;
const sourceCode = `\
test('example test', async () => {
await gen('task 1', { page, test });
});`;

const ident = staticStore.makeIdent("example test", "task 1");
staticStore.makeStatic({ ident, expression: "" });
Expand Down Expand Up @@ -83,11 +81,10 @@ test(
});

test("should handle source code with no relevant gen calls", () => {
const sourceWithNoGenCalls = `
test('example test', async () => {
await someOtherFunction();
});
`;
const sourceWithNoGenCalls = `\
test('example test', async () => {
await someOtherFunction();
});`;
const result = pwCompile(sourceWithNoGenCalls, staticStore);
expect(result).toBe(sourceWithNoGenCalls);
});
Expand Down

0 comments on commit 6c25d72

Please sign in to comment.