@@ -14,8 +14,10 @@ const simpleWrapperUri = `fs/${wrapperPath}`;
1414
1515describe ( "Embedded wrapper" , ( ) => {
1616 it ( "can invoke an embedded wrapper" , async ( ) => {
17- const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) )
18- const wasmModuleBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.wasm" ) )
17+ const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) ) ;
18+ const wasmModuleBuffer = fs . readFileSync (
19+ path . join ( wrapperPath , "wrap.wasm" )
20+ ) ;
1921
2022 let wrapper : Wrapper = await WasmWrapper . from (
2123 manifestBuffer ,
@@ -33,19 +35,18 @@ describe("Embedded wrapper", () => {
3335 method : "add" ,
3436 args : {
3537 a : 1 ,
36- b : 1
38+ b : 1 ,
3739 } ,
3840 } ) ;
3941
40- if ( ! result . ok ) fail ( result . error ) ;
41- expect ( result . value ) . toBeTruthy ( ) ;
42- expect ( typeof result . value ) . toBe ( "number" ) ;
43- expect ( result . value ) . toEqual ( 2 ) ;
42+ expect ( result ) . toStrictEqual ( ResultOk ( 2 ) ) ;
4443 } ) ;
4544
4645 it ( "can get a file from wrapper" , async ( ) => {
47- const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) )
48- const wasmModuleBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.wasm" ) )
46+ const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) ) ;
47+ const wasmModuleBuffer = fs . readFileSync (
48+ path . join ( wrapperPath , "wrap.wasm" )
49+ ) ;
4950 const testFilePath = "hello.txt" ;
5051 const testFileText = "Hello Test!" ;
5152
@@ -63,8 +64,10 @@ describe("Embedded wrapper", () => {
6364 } ) ;
6465
6566 it ( "can add embedded wrapper through file reader" , async ( ) => {
66- const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) )
67- const wasmModuleBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.wasm" ) )
67+ const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) ) ;
68+ const wasmModuleBuffer = fs . readFileSync (
69+ path . join ( wrapperPath , "wrap.wasm" )
70+ ) ;
6871 const testFilePath = "hello.txt" ;
6972 const testFileText = "Hello Test!" ;
7073
@@ -86,8 +89,10 @@ describe("Embedded wrapper", () => {
8689 } ) ;
8790
8891 it ( "can add embedded wrapper with async wrap manifest" , async ( ) => {
89- const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) )
90- const wasmModuleBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.wasm" ) )
92+ const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) ) ;
93+ const wasmModuleBuffer = fs . readFileSync (
94+ path . join ( wrapperPath , "wrap.wasm" )
95+ ) ;
9196 const testFilePath = "hello.txt" ;
9297 const testFileText = "Hello Test!" ;
9398
@@ -109,8 +114,10 @@ describe("Embedded wrapper", () => {
109114 } ) ;
110115
111116 it ( "can add embedded wrapper with async wasm module" , async ( ) => {
112- const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) )
113- const wasmModuleBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.wasm" ) )
117+ const manifestBuffer = fs . readFileSync ( path . join ( wrapperPath , "wrap.info" ) ) ;
118+ const wasmModuleBuffer = fs . readFileSync (
119+ path . join ( wrapperPath , "wrap.wasm" )
120+ ) ;
114121 const testFilePath = "hello.txt" ;
115122 const testFileText = "Hello Test!" ;
116123
@@ -148,25 +155,19 @@ const testEmbeddedWrapperWithFile = async (
148155 const receivedManifestResult = await client . getFile ( simpleWrapperUri , {
149156 path : "wrap.info" ,
150157 } ) ;
151- if ( ! receivedManifestResult . ok ) fail ( receivedManifestResult . error ) ;
152- const receivedManifest = receivedManifestResult . value as Uint8Array ;
153- expect ( receivedManifest ) . toEqual ( expectedManifest ) ;
158+ expect ( receivedManifestResult ) . toEqual ( ResultOk ( expectedManifest ) ) ;
154159
155- const expectedWasmModule =
156- await fs . promises . readFile ( `${ wrapperPath } /wrap.wasm` ) ;
160+ const expectedWasmModule = await fs . promises . readFile (
161+ `${ wrapperPath } /wrap.wasm`
162+ ) ;
157163 const receivedWasmModuleResult = await client . getFile ( simpleWrapperUri , {
158164 path : "wrap.wasm" ,
159165 } ) ;
160- if ( ! receivedWasmModuleResult . ok ) fail ( receivedWasmModuleResult . error ) ;
161- const receivedWasmModule = receivedWasmModuleResult . value as Uint8Array ;
162- expect ( receivedWasmModule ) . toEqual ( expectedWasmModule ) ;
166+ expect ( receivedWasmModuleResult ) . toEqual ( ResultOk ( expectedWasmModule ) ) ;
163167
164168 const receivedHelloFileResult = await client . getFile ( simpleWrapperUri , {
165169 path : filePath ,
166170 encoding : "utf-8" ,
167171 } ) ;
168- if ( ! receivedHelloFileResult . ok ) fail ( receivedHelloFileResult . error ) ;
169- const receivedHelloFile = receivedHelloFileResult . value as Uint8Array ;
170-
171- expect ( receivedHelloFile ) . toEqual ( fileText ) ;
172+ expect ( receivedHelloFileResult ) . toEqual ( ResultOk ( fileText ) ) ;
172173} ;
0 commit comments