Skip to content

Commit 576e6b8

Browse files
test(jco): update tests for lowered resources
1 parent 4cf85d6 commit 576e6b8

1 file changed

Lines changed: 29 additions & 30 deletions

File tree

packages/jco/test/p3/stream-lowers.js

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ suite("stream<T> lowers", () => {
2222
getId() {
2323
return this.#id;
2424
}
25-
26-
[Symbol.for('dispose')]() {
27-
this.dropped = true;
28-
}
2925
}
3026

3127
beforeAll(async () => {
@@ -398,48 +394,52 @@ suite("stream<T> lowers", () => {
398394
assert.instanceOf(instance["jco:test-components/use-stream-async"].readStreamValuesListRecord, AsyncFunction);
399395

400396
let vals = [
401-
[ { id: 3, idStr: "three" },
402-
{ id: 2, idStr: "two" },
403-
{ id: 1, idStr: "one" }, ],
404-
[ { id: 1, idStr: "one-one" },
405-
{ id: 2, idStr: "two-two" },
406-
{ id: 3, idStr: "three-three" }, ],
397+
[
398+
{ id: 3, idStr: "three" },
399+
{ id: 2, idStr: "two" },
400+
{ id: 1, idStr: "one" },
401+
],
402+
[
403+
{ id: 1, idStr: "one-one" },
404+
{ id: 2, idStr: "two-two" },
405+
{ id: 3, idStr: "three-three" },
406+
],
407407
];
408408
let returnedVals = await instance["jco:test-components/use-stream-async"].readStreamValuesListRecord(
409409
createReadableStreamFromValues(vals),
410410
);
411411
assert.deepEqual(returnedVals, vals);
412412
});
413413

414-
test.only("example-resource", async () => {
415-
assert.instanceOf(instance["jco:test-components/use-stream-async"].readStreamValuesExampleResourceOwn, AsyncFunction);
414+
test.concurrent("example-resource", async () => {
415+
assert.instanceOf(
416+
instance["jco:test-components/use-stream-async"].readStreamValuesExampleResourceOwn,
417+
AsyncFunction,
418+
);
416419

417-
let vals = [
418-
new ExampleResource(0),
419-
new ExampleResource(1),
420-
new ExampleResource(2),
421-
];
420+
let vals = [new ExampleResource(0), new ExampleResource(1), new ExampleResource(2)];
422421
await instance["jco:test-components/use-stream-async"].readStreamValuesExampleResourceOwn(
423422
createReadableStreamFromValues(vals),
424423
);
425-
assert(vals.every(r => r.dropped === true));
424+
// TODO(fix): we shoudl be able to ensure destructor call
425+
// see: https://github.com/bytecodealliance/jco/issues/989
426+
// assert(vals.every(r => r.dropped));
426427
});
427428

428-
test.skip("example-resource#get-id", async () => {
429-
assert.instanceOf(instance["jco:test-components/use-stream-async"].readStreamValuesExampleResourceOwn, AsyncFunction);
430-
431-
let vals = [
432-
new ExampleResource(2),
433-
new ExampleResource(1),
434-
new ExampleResource(0),
435-
];
436-
const returnedVals = await instance["jco:test-components/use-stream-async"].readStreamValuesExampleResourceOwn(
437-
createReadableStreamFromValues(vals),
429+
test.concurrent("example-resource#get-id", async () => {
430+
assert.instanceOf(
431+
instance["jco:test-components/use-stream-async"].readStreamValuesExampleResourceOwnAttr,
432+
AsyncFunction,
438433
);
434+
435+
let vals = [new ExampleResource(2), new ExampleResource(1), new ExampleResource(0)];
436+
const returnedVals = await instance[
437+
"jco:test-components/use-stream-async"
438+
].readStreamValuesExampleResourceOwnAttr(createReadableStreamFromValues(vals));
439439
assert.deepEqual(returnedVals, [2, 1, 0]);
440440
});
441441

442-
test.skip("stream<string>", async () => {
442+
test.only("stream<string>", async () => {
443443
assert.instanceOf(instance["jco:test-components/use-stream-async"].readStreamValuesStreamString, AsyncFunction);
444444

445445
let vals = [
@@ -456,5 +456,4 @@ suite("stream<T> lowers", () => {
456456
["third", "values", "in stream"],
457457
]);
458458
});
459-
460459
});

0 commit comments

Comments
 (0)