- From: Adam Rice <notifications@github.com>
- Date: Fri, 04 Nov 2016 14:13:27 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Message-ID: <whatwg/streams/pull/597/review/7237437@github.com>
ricea commented on this pull request.
> @@ -9,6 +9,36 @@ if (self.importScripts) {
const error1 = new Error('error1');
error1.name = 'error1';
+test(() => {
+ assert_throws(error1, () => {
+ new WritableStream({
+ get start() {
+ throw error1;
+ }
+ });
+ }, 'constructor throws same error from throwing start getter');
When describing an assert or a test, please use the word 'should', ie. 'when start getter throws, constructor should throw the same object'.
I use https://www.chromium.org/blink/serviceworker/testing#TOC-Layout-Tests-Style as my style guide for web-platform-tests.
> +
+ return promise_rejects(t, error1, writer.close(), 'close should reject with the thrown error');
+}, 'close: throwing getter should cause writer close() to reject');
+
+promise_test(t => {
+ const ws = new WritableStream({
+ get write() {
+ throw error1;
+ }
+ });
+
+ const writer = ws.getWriter();
+
+ return promise_rejects(t, error1, writer.write('a'), 'write should reject with the thrown error')
+ .then(() => {
+ return promise_rejects(t, error1, writer.closed, 'closed should reject with the thrown error');
Personally I wouldn't bother with the () here, but I am not fussy.
> @@ -41,4 +43,245 @@ test(() => {
assert_equals(writer.desiredSize, 1, 'writer.desiredSize should be 1');
}, 'TransformStream writable starts in the writable state');
+
+promise_test(() => {
+ const ts = new TransformStream();
+
+ const writer = ts.writable.getWriter();
+ writer.write('a');
+ assert_equals(writer.desiredSize, 0, 'writer.desiredSize should be 0 after write()');
+
+ return ts.readable.getReader().read().then(result => {
+ assert_equals(result.value, 'a',
+ 'result from reading the readable is the same as was written to writable');
+ assert_false(result.done, 'stream is not done');
This is a good example of why phrasing descriptions using the word 'should' is helpful. Writing 'stream should not be done' makes it a lot clearer what the expected result is.
--
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/597#pullrequestreview-7237437
Received on Friday, 4 November 2016 21:13:59 UTC