Skip to content

Commit 86f849c

Browse files
committed
feat: add static-resolver redirect test
1 parent d354d77 commit 86f849c

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
"wrap://test/from => StaticResolver - Redirect (wrap://test/from - wrap://test/to) => uri (wrap://test/to)"
3+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
Uri,
3+
UriResolutionContext,
4+
} from "@polywrap/core-js";
5+
import { expectHistory } from "../helpers/expectHistory";
6+
import { PolywrapCoreClient } from "@polywrap/core-client-js";
7+
import { StaticResolver } from "../../static";
8+
9+
jest.setTimeout(20000);
10+
11+
describe("StaticResolver", () => {
12+
it("can redirect a uri", async () => {
13+
const uri = new Uri("test/from");
14+
15+
const client = new PolywrapCoreClient({
16+
resolver: StaticResolver.from([
17+
{
18+
from: Uri.from("test/from"),
19+
to: Uri.from("test/to"),
20+
},
21+
]),
22+
});
23+
24+
let resolutionContext = new UriResolutionContext();
25+
let result = await client.tryResolveUri({ uri, resolutionContext });
26+
27+
await expectHistory(
28+
resolutionContext.getHistory(),
29+
"static-resolver",
30+
"can-redirect-a-uri"
31+
);
32+
33+
if (!result.ok) {
34+
fail(result.error);
35+
}
36+
37+
if (result.value.type !== "uri") {
38+
fail("Expected a uri, received: " + result.value.type);
39+
}
40+
41+
expect(result.value.uri.uri).toEqual("wrap://test/to");
42+
});
43+
});

0 commit comments

Comments
 (0)