Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dOrgJelli committed Aug 23, 2022
1 parent a2c2ef6 commit 8cb0142
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
8 changes: 5 additions & 3 deletions packages/js/client/src/PolywrapClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getDefaultClientConfig } from "./default-client-config";
import { SimpleCache } from "./cache/SimpleWrapperCache";

import { v4 as uuid } from "uuid";
import {
Expand Down Expand Up @@ -46,6 +45,7 @@ import {
PluginPackage,
RunOptions,
GetManifestOptions,
SimpleCache,
} from "@polywrap/core-js";
import { msgpackEncode, msgpackDecode } from "@polywrap/msgpack-js";
import { WrapManifest } from "@polywrap/wrap-manifest-types-js";
Expand Down Expand Up @@ -97,11 +97,13 @@ export class PolywrapClient implements Client {

if (config.wrapperCache) {
this._wrapperCache = config.wrapperCache;
} else {
this._wrapperCache = new SimpleCache();
}
}

if (!this._wrapperCache) {
this._wrapperCache = new SimpleCache();
}

if (!options?.noDefaults) {
this._addDefaultConfig();
}
Expand Down
1 change: 0 additions & 1 deletion packages/js/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ export * from "./createPolywrapClient";
export * from "./default-client-config";
export * from "./wasm";
export * from "./plugin";
export * from "./cache";
export * from "@polywrap/core-js";
20 changes: 11 additions & 9 deletions packages/js/core/src/__tests__/resolveUri.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
SubscribeOptions,
Subscription,
PluginPackage,
SimpleCache,
GetManifestOptions,
} from "..";

import { WrapManifest } from "@polywrap/wrap-manifest-types-js";
Expand Down Expand Up @@ -106,7 +108,7 @@ describe("resolveUri", () => {
encoded: false
}),
getFile: (options: GetFileOptions, client: Client) => Promise.resolve(""),
getManifest: (client: Client) => Promise.resolve({} as WrapManifest)
getManifest: (options: GetManifestOptions, client: Client) => Promise.resolve({} as WrapManifest)
};
};

Expand Down Expand Up @@ -238,7 +240,7 @@ describe("resolveUri", () => {
new Uri("ens/test.eth"),
uriResolvers,
client(wrappers, plugins, interfaces),
new Map<string, Wrapper>(),
new SimpleCache(),
);

expect(result.wrapper).toBeTruthy();
Expand All @@ -260,7 +262,7 @@ describe("resolveUri", () => {
new Uri("my/something-different"),
uriResolvers,
client(wrappers, plugins, interfaces),
new Map<string, Wrapper>(),
new SimpleCache(),
);

expect(result.wrapper).toBeTruthy();
Expand All @@ -282,7 +284,7 @@ describe("resolveUri", () => {
new Uri("ens/ens"),
uriResolvers,
client(wrappers, plugins, interfaces),
new Map<string, Wrapper>(),
new SimpleCache(),
);

expect(result.wrapper).toBeTruthy();
Expand All @@ -304,7 +306,7 @@ describe("resolveUri", () => {
new Uri("my/something-different"),
uriResolvers,
client(wrappers, plugins, interfaces),
new Map<string, Wrapper>(),
new SimpleCache(),
);

expect(result.wrapper).toBeTruthy();
Expand Down Expand Up @@ -339,7 +341,7 @@ describe("resolveUri", () => {
new Uri("some/wrapper"),
uriResolvers,
client(wrappers, plugins, interfaces, circular),
new Map<string, Wrapper>(),
new SimpleCache(),
).catch((e: Error) =>
expect(e.message).toMatch(/Infinite loop while resolving URI/)
);
Expand All @@ -363,7 +365,7 @@ describe("resolveUri", () => {
new Uri("some/wrapper"),
uriResolvers,
client(wrappers, plugins, interfaces, missingFromProperty),
new Map<string, Wrapper>(),
new SimpleCache(),
).catch((e: Error) =>
expect(e.message).toMatch(
"Redirect missing the from property.\nEncountered while resolving wrap://some/wrapper"
Expand All @@ -387,7 +389,7 @@ describe("resolveUri", () => {
new Uri("some/wrapper"),
uriResolvers,
client(wrappers, pluginRegistrations, interfaces),
new Map<string, Wrapper>(),
new SimpleCache(),
);

expect(result.wrapper).toBeTruthy();
Expand Down Expand Up @@ -425,7 +427,7 @@ describe("resolveUri", () => {
plugins,
interfaces
),
new Map<string, Wrapper>(),
new SimpleCache(),
);

expect(resolvedUri).toEqual(uri);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Uri, Wrapper, WrapperCache } from "@polywrap/core-js";
import { Uri, Wrapper, WrapperCache } from "../types";

export class SimpleCache implements WrapperCache {
private _map: Map<string, Wrapper> = new Map();
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/js/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./types";
export * from "./algorithms";
export * from "./cache";
export * from "./interfaces";
export * from "./uri-resolution/core";
export * from "./uri-resolution/resolvers";
Expand Down

0 comments on commit 8cb0142

Please sign in to comment.