From 80c6eefd1dc4256e104acdba9c426fba268ea5dd Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 24 Oct 2023 19:06:53 +0500 Subject: [PATCH] wasm templates now use app codegen for testing --- .../src/__tests__/e2e/integration.spec.ts | 16 +++++----------- .../module/__tests__/e2e/integration.spec.ts | 16 +++++----------- .../src/__tests__/e2e/integration.spec.ts | 16 +++++----------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); diff --git a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); diff --git a/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); });