Re: [whatwg/streams] Port constructor tests to web-platform-tests (#524)

ricea commented on this pull request.



> +test(() => {
+  const ws = new WritableStream();
+}, 'WritableStream should be constructible with no arguments');
+
+test(() => {
+  const ws = new WritableStream({});
+
+  const writer = ws.getWriter();
+
+  assert_equals(typeof writer.write, 'function', 'writer should have a write method');
+  assert_equals(typeof writer.abort, 'function', 'writer should have an abort method');
+  assert_equals(typeof writer.close, 'function', 'writer should have a close method');
+
+  assert_equals(writer.desiredSize, 1, 'desiredSize should start at 1');
+
+  assert_idl_attribute(writer, 'ready', 'writer should have a ready attribute');

I decided that they were morally equivalent. assert_idl_attribute() is basically a check that the property exists on the prototype.

For the time being I have weaken the check to just require that the property is defined. The original test checked that the property was truthy, but that is unnatural in testharness.js. assert_true requires an actual boolean, not just truthiness, so you'd have to write assert_true(Boolean(writer.ready)) which feels awkward.

-- 
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/524

Received on Thursday, 6 October 2016 04:21:26 UTC