/*
 * Copyright (c) 2015 peeracle contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/* eslint-disable */
'use strict';

if (!Peeracle) {
  var Peeracle = require('../peeracle');
}

describe('BinaryStream', function () {
  var buffer;
  var binaryStream;
  it('should create a Uint8Array with 32 zeroes', function () {
    buffer = new Uint8Array(32);
    expect(buffer).not.toBeNull();
    expect(buffer.length).toEqual(32);
  });
  it('should create a new BinaryStream from that array', function () {
    binaryStream = new Peeracle.BinaryStream(buffer);
  });
});
@@ -1164,17 +1164,23 @@
 if (
-!
+typeof 
 Peeracle
 ) %7B%0A
@@ -1175,16 +1175,32 @@
 Peeracle
+ === 'undefined'
 ) %7B%0A  va
@@ -1294,29 +1294,126 @@
 ffer
-;%0A  var binaryStream;
+ = new Uint8Array(32);%0A  var binaryStream = new Peeracle.BinaryStream(buffer);%0A  var byte;%0A  var bytes;%0A  var string;%0A
 %0A  i
@@ -1445,23 +1445,8 @@
 rray
- with 32 zeroes
 ', f
@@ -1491,16 +1491,78 @@
 ay(32);%0A
+    for (var i = 0; i %3C 32; ++i) %7B%0A      buffer%5Bi%5D = 0;%0A    %7D%0A
     expe
@@ -1633,16 +1633,17 @@
 ;%0A  %7D);%0A
+%0A
   it('sh
@@ -1651,117 +1651,1493 @@
 uld 
-create a new BinaryStream from that array', function () %7B%0A    binaryStream = new Peeracle.BinaryStream(buffer
+write a random byte', function () %7B%0A    byte = Peeracle.Utils.trunc(Math.random() * 255);%0A    binaryStream.writeByte(byte);%0A  %7D);%0A%0A  it('should read a zero', function () %7B%0A    var result = binaryStream.readByte();%0A    expect(result).toEqual(0);%0A  %7D);%0A%0A  it('should read the random byte', function () %7B%0A    var result;%0A%0A    binaryStream.seek(0);%0A    result = binaryStream.readByte();%0A    expect(result).toEqual(byte);%0A  %7D);%0A%0A  it('should write some random bytes', function () %7B%0A    var string = Math.random().toString(36).slice(2);%0A%0A    bytes = new Uint8Array(string.length);%0A    for (var i = 0, j = string.length; i %3C j; ++i) %7B%0A      bytes%5Bi%5D = string.charCodeAt(i);%0A    %7D%0A%0A    binaryStream.seek(0);%0A    binaryStream.writeBytes(bytes);%0A  %7D);%0A%0A  it('should read the random bytes', function () %7B%0A    var result;%0A%0A    binaryStream.seek(0);%0A    result = binaryStream.readBytes(bytes.length);%0A    expect(result).toEqual(bytes);%0A  %7D);%0A%0A  it('should write a random string', function () %7B%0A    string = Math.random().toString(36).slice(2);%0A%0A    binaryStream.seek(0);%0A    binaryStream.writeString(string);%0A  %7D);%0A%0A  it('should read the random string', function () %7B%0A    var result;%0A%0A    binaryStream.seek(0);%0A    result = binaryStream.readString();%0A    expect(result).toEqual(string);%0A  %7D);%0A%0A  it('should read the two first bytes of the random string', function () %7B%0A    var result;%0A%0A    binaryStream.seek(0);%0A    result = binaryStream.readString(2);%0A    expect(result).toEqual(string.slice(0, 2)
 );%0A 

Write basic BinaryStream unit tests, with bytes and strings functions