Skip to content

Commit

Permalink
wasm templates now use app codegen for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
krisbitney committed Oct 24, 2023
1 parent 9cda933 commit 80c6eef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { PolywrapClient } from "@polywrap/client-js";
import * as App from "../types/wrap";
import path from "path";

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<App.Template_SampleResult>({
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);
});
});
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { PolywrapClient } from "@polywrap/client-js";
import * as App from "../types/wrap";
import path from "path";

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<App.Template_SampleResult>({
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);
});
});
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { PolywrapClient } from "@polywrap/client-js";
import * as App from "../types/wrap";
import path from "path";

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<App.Template_SampleResult>({
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);
});
});

0 comments on commit 80c6eef

Please sign in to comment.