Skip to content

Commit f10b266

Browse files
refactor(jco): stream tests
1 parent 4b8eb45 commit f10b266

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

packages/jco/test/common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export async function getDefaultComponentFixtures() {
5858

5959
/** Check the values of a given stream (normally returned from a component) */
6060
export async function checkStreamValues(args) {
61-
const { stream, typeName, assertEqFn, partial } = args ?? {};
62-
const expectedValues = args.expectedValues ?? [];
61+
const { expectedValues, stream, typeName, assertEqFn, partial } = args ?? {};
62+
assert.isNotEmpty(expectedValues);
6363

6464
// Ensure the values produced match expected
6565
const eq = assertEqFn ?? assert.equal;

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,7 @@ suite("stream<T> lifts", () => {
258258
await checkStreamValues({ stream, expectedValues: vals, typeName: "record", assertEqFn: assert.deepEqual });
259259
});
260260

261-
// TODO(fix): RACY!!! values are coming back in the wrong order!
262-
263-
// TODO: Broken
264-
test.only("variant", async () => {
261+
test.concurrent("variant", async () => {
265262
const instance = await getInstance();
266263
assert.instanceOf(instance["jco:test-components/get-stream-async"].getStreamVariant, AsyncFunction);
267264

@@ -280,7 +277,7 @@ suite("stream<T> lifts", () => {
280277
// Ensure first two values match
281278
await checkStreamValues({
282279
stream,
283-
vals: [
280+
expectedValues: [
284281
// TODO: wit type representation smoothing mismatch,
285282
// non-nullable option<t> values are *not* wrapped as objects
286283
{ tag: "maybe-u32", val: { tag: "some", val: 123 } },
@@ -294,7 +291,7 @@ suite("stream<T> lifts", () => {
294291
// Check float member
295292
await checkStreamValues({
296293
stream,
297-
vals: vals.slice(2, 3),
294+
expectedValues: vals.slice(2, 3),
298295
typeName: "variant<float>",
299296
partial: true,
300297
assertEqFn: (value, expected) => {
@@ -308,14 +305,13 @@ suite("stream<T> lifts", () => {
308305
// Check rest of values
309306
await checkStreamValues({
310307
stream,
311-
vals: vals.slice(3),
308+
expectedValues: vals.slice(3),
312309
typeName: "variant<rest>",
313310
assertEqFn: assert.deepEqual,
314311
});
315312
});
316313

317-
// TODO: BROKEN
318-
test.skip("variant layout", async () => {
314+
test.concurrent("variant layout", async () => {
319315
const instance = await getInstance();
320316
assert.instanceOf(instance["jco:test-components/get-stream-async"].getStreamLayoutVariant, AsyncFunction);
321317
assert.instanceOf(instance["jco:test-components/get-stream-async"].getStreamVariantStringRecord, AsyncFunction);
@@ -324,7 +320,7 @@ suite("stream<T> lifts", () => {
324320
let stream = await instance["jco:test-components/get-stream-async"].getStreamLayoutVariant(variants);
325321
await checkStreamValues({
326322
stream,
327-
vals: variants,
323+
expectedValues: variants,
328324
typeName: "layout-variant",
329325
assertEqFn: assert.deepEqual,
330326
});
@@ -336,7 +332,7 @@ suite("stream<T> lifts", () => {
336332
stream = await instance["jco:test-components/get-stream-async"].getStreamVariantStringRecord(records);
337333
await checkStreamValues({
338334
stream,
339-
vals: records,
335+
expectedValues: records,
340336
typeName: "variant-string-record",
341337
assertEqFn: assert.deepEqual,
342338
});

0 commit comments

Comments
 (0)