it('should not have a blob or a blob builder in the global namespace, or blob should not be a constructor function if the module exports false',function(){
try{
varab=(newUint8Array(5)).buffer;
global.Blob([ab]);
expect().fail('Blob shouldn\'t be constructable');
}catch(e){}
varBlobBuilder=global.BlobBuilder
||global.WebKitBlobBuilder
||global.MSBlobBuilder
||global.MozBlobBuilder;
expect(BlobBuilder).to.be(undefined);
});
}else{
it('should encode a proper sized blob when given a string argument',function(){
varb=newBlob(['hi']);
expect(b.size).to.be(2);
});
it('should encode a blob with proper size when given two strings as arguments',function(){
varb=newBlob(['hi','hello']);
expect(b.size).to.be(7);
});
it('should encode arraybuffers with right content',function(done){
varary=newUint8Array(5);
for(vari=0;i<5;i++)ary[i]=i;
varb=newBlob([ary.buffer]);
varfr=newFileReader();
fr.onload=function(){
varnewAry=newUint8Array(this.result);
for(vari=0;i<5;i++)expect(newAry[i]).to.be(i);
done();
};
fr.readAsArrayBuffer(b);
});
it('should encode typed arrays with right content',function(done){
varary=newUint8Array(5);
for(vari=0;i<5;i++)ary[i]=i;
varb=newBlob([ary]);
varfr=newFileReader();
fr.onload=function(){
varnewAry=newUint8Array(this.result);
for(vari=0;i<5;i++)expect(newAry[i]).to.be(i);
done();
};
fr.readAsArrayBuffer(b);
});
it('should encode sliced typed arrays with right content',function(done){
varary=newUint8Array(5);
for(vari=0;i<5;i++)ary[i]=i;
varb=newBlob([ary.subarray(2)]);
varfr=newFileReader();
fr.onload=function(){
varnewAry=newUint8Array(this.result);
for(vari=0;i<3;i++)expect(newAry[i]).to.be(i+2);
done();
};
fr.readAsArrayBuffer(b);
});
it('should encode with blobs',function(done){
varary=newUint8Array(5);
for(vari=0;i<5;i++)ary[i]=i;
varb=newBlob([newBlob([ary.buffer])]);
varfr=newFileReader();
fr.onload=function(){
varnewAry=newUint8Array(this.result);
for(vari=0;i<5;i++)expect(newAry[i]).to.be(i);
done();
};
fr.readAsArrayBuffer(b);
});
it('should enode mixed contents to right size',function(){
varary=newUint8Array(5);
for(vari=0;i<5;i++)ary[i]=i;
varb=newBlob([ary.buffer,'hello']);
expect(b.size).to.be(10);
});
it('should accept mime type',function(){
varb=newBlob(['hi','hello'],{type:'text/html'});
expect(b.type).to.be('text/html');
});
it('should be an instance of constructor',function(){