Sha256: a1315c35c31421707304f0e613bcce84aaa2277f6bd8de9beb3c4a5e6c5c217f

Contents?: true

Size: 1.5 KB

Versions: 176

Compression:

Stored size: 1.5 KB

Contents

var Blob = require('../');
var expect = require('expect.js');

if (!Blob) {
  return;
}

describe('blob', function() {
  it('should encode a proper sized blob when given a string argument', function() {
    var b = new Blob(['hi']);
    expect(b.size).to.be(2);
  });

  it('should encode a blob with proper size when given two strings as arguments', function() {
    var b = new Blob(['hi', 'hello']);
    expect(b.size).to.be(7);
  });

  it('should encode arraybuffers with right content', function() {
    var ary = new Uint8Array(5);
    for (var i = 0; i < 5; i++) ary[i] = i;
    var b = new Blob([ary.buffer]);
    var fr = new FileReader();
    fr.onload = function() {
      var newAry = new Uint8Array(this.result);
      for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
    };
  });

  it('should encode with blobs', function() {
    var ary = new Uint8Array(5);
    for (var i = 0; i < 5; i++) ary[i] = i;
    var b = new Blob([new Blob([ary.buffer])]);
    var fr = new FileReader();
    fr.onload = function() {
      var newAry = new Uint8Array(this.result);
      for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
    };
  });

  it('should enode mixed contents to right size', function() {
    var ary = new Uint8Array(5);
    for (var i = 0; i < 5; i++) ary[i] = i;
    var b = new Blob([ary.buffer, 'hello']);
    expect(b.size).to.be(10);
  });

  it('should accept mime type', function() {
    var b = new Blob(['hi', 'hello'], { type: 'text/html' });
    expect(b.type).to.be('text/html');
  });
});

Version data entries

176 entries across 88 versions & 2 rubygems

Version Path
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/test/index.js
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js