Re: [whatwg/streams] Add tests for TransformStream backpressure (#773)

ricea commented on this pull request.



> +
+promise_test(() => {
+  const ts = new TransformStream();
+  const writer = ts.writable.getWriter();
+  const reader = ts.readable.getReader();
+  const events = [];
+  writer.write('a').then(() => events.push('a'));
+  writer.write('b').then(() => events.push('b'));
+  writer.close().then(() => events.push('closed'));
+  return flushAsyncEvents().then(() => {
+    assert_array_equals(events, [], 'no writes should have resolved yet');
+    return reader.read();
+  }).then(({ value, done }) => {
+    assert_false(done, 'done should not be true');
+    assert_equals('a', value, 'value should be "a"');
+    return delay(0);

I tend to lose track of which I'm supposed to be using too. They should probably have better names.

flushAsyncEvents() is used when making an assertion that something will not happen. It's equivalent to delay(Infinity) but with the benefit that the test actually completes :-)

delay(0) is used when making an assertion that something will happen after an unspecified number of microtasks have been executed.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/773#discussion_r134675903

Received on Wednesday, 23 August 2017 07:30:05 UTC