File tree Expand file tree Collapse file tree
packages/uri-resolvers/src/__tests__/static-resolver Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ [
2+ " wrap://test/from => StaticResolver - Redirect (wrap://test/from - wrap://test/to) => uri (wrap://test/to)"
3+ ]
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments