Skip to content
This repository
Browse code

Merge pull request #52 from facebook/blobbuilder

Adding blobbuilder test.
NOTE: needs much more
  • Loading branch information...
commit 5e8b47ec4e0e0a3fd53a89da5046b69a49a701da 2 parents 612909f + dd5354b
Robin Berjon authored June 06, 2012
4  tests/blobbuilder/config.yml
... ...
@@ -0,0 +1,4 @@
  1
+---
  2
+  r: 1
  3
+  spec: "http://dev.w3.org/2009/dap/file-system/file-writer.html#the-blobbuilder-interface"
  4
+  title: "BlobBuilder"
39  tests/blobbuilder/test.js
... ...
@@ -0,0 +1,39 @@
  1
+test("BlobBuilder", function() {
  2
+  var BlobBuilder = H.API( window, "BlobBuilder", true );
  3
+
  4
+  assert( !!BlobBuilder, "BlobBuilder supported" );
  5
+});
  6
+
  7
+test("BlobBuilder, Blob Slice", function() {
  8
+  var BlobBuilder = H.API( window, "BlobBuilder", true ),
  9
+      value = "Oh Hai!",
  10
+      builder, blob, slice;
  11
+
  12
+  if ( !BlobBuilder ) {
  13
+    assert( false, "BlobBuilder not supported, skipping tests" );
  14
+  } else {
  15
+    blob = (new BlobBuilder()).getBlob();
  16
+    slice = H.API( blob, "slice", true );
  17
+
  18
+    assert( slice, "blob.slice supported (" + slice.name + ")" );
  19
+  }
  20
+});
  21
+
  22
+test("BlobBuilder In Practice", function() {
  23
+  var BlobBuilder = H.API( window, "BlobBuilder", true ),
  24
+      value = "Oh Hai!",
  25
+      builder, blob;
  26
+
  27
+  if ( !BlobBuilder ) {
  28
+    assert( false, "BlobBuilder not supported, skipping tests" );
  29
+  } else {
  30
+    builder = new BlobBuilder();
  31
+    builder.append("Oh Hai!");
  32
+
  33
+    blob = builder.getBlob();
  34
+
  35
+    assert( H.isKindOf( blob, "Blob" ), "getBlob() supported" );
  36
+    assert( blob.size === value.length, "blob.size is correct");
  37
+    assert( "type" in blob, "blob.type supported" );
  38
+  }
  39
+});

0 notes on commit 5e8b47e

Please sign in to comment.
Something went wrong with that request. Please try again.