Skip to content

Commit

Permalink
test: reenable ComponentizeJS test cases (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Dec 1, 2023
1 parent 7db3985 commit 1307064
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"terser": "^5.16.1"
},
"devDependencies": {
"@bytecodealliance/componentize-js": "^0.4.1",
"@bytecodealliance/componentize-js": "^0.5.0",
"@types/node": "^18.11.17",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
Expand Down
2 changes: 1 addition & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export async function cliTest (fixtures) {
}]);
});

test.skip('Componentize', async () => {
test('Componentize', async () => {
const { stdout, stderr } = await exec(jcoPath,
'componentize',
'test/fixtures/componentize/source.js',
Expand Down
23 changes: 11 additions & 12 deletions test/fixtures/componentize/wasi-http-proxy/source.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { handle } from 'wasi:http/[email protected]05';
import { handle } from 'wasi:http/[email protected]10';
import {
Fields,
OutgoingRequest,
OutgoingBody,
} from 'wasi:http/[email protected]05';
} from 'wasi:http/[email protected]10';

const sendRequest = (
method,
Expand All @@ -17,19 +17,19 @@ const sendRequest = (
{
let encoder = new TextEncoder();

const request = new OutgoingRequest(
method,
pathWithQuery,
scheme,
authority,
const req = new OutgoingRequest(
new Fields([
['User-agent', encoder.encode('WASI-HTTP/0.0.1')],
['Content-type', encoder.encode('application/json')],
])
);
req.setScheme(scheme);
req.setMethod(method);
req.setPathWithQuery(pathWithQuery);
req.setAuthority(authority);

if (body) {
const outgoingBody = request.write();
const outgoingBody = req.body();
{
const bodyStream = outgoingBody.write();
bodyStream.blockingWriteAndFlush(encoder.encode(body));
Expand All @@ -39,7 +39,8 @@ const sendRequest = (
OutgoingBody.finish(outgoingBody);
}

const futureIncomingResponse = handle(request);
const futureIncomingResponse = handle(req);
futureIncomingResponse.subscribe().block();
incomingResponse = futureIncomingResponse.get().val.val;
}

Expand All @@ -53,10 +54,8 @@ const sendRequest = (
const incomingBody = incomingResponse.consume();
{
const bodyStream = incomingBody.stream();
// const bodyStreamPollable = bodyStream.subscribe();
bodyStream.subscribe().block();
const buf = bodyStream.read(50n);
// TODO: actual streaming
// TODO: explicit drops
responseBody = buf.length > 0 ? new TextDecoder().decode(buf) : undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion test/preview2.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function preview2Test () {
strictEqual(stderr, 'writing to stderr: hello, world\n');
});

test.skip('wasi-http-proxy', async () => {
test('wasi-http-proxy', async () => {
const server = createServer(async (req, res) => {
if (req.url == '/api/examples') {
res.writeHead(200, {
Expand Down

0 comments on commit 1307064

Please sign in to comment.