'use strict';

const chai = require('chai');
const crypto = require('crypto');
const lzo = require('../index');

const expect = chai.expect;

let data = crypto.randomBytes(100),
    compressed;

describe('Compression', () => {
  it('Should throw if nothing is passed', () => 
    expect(() => lzo.compress()).to.throw() );

  it('Should properly compress and not throw', () => {
    expect(() => {
      compressed = lzo.compress(data)
    }).to.not.throw();
  });
});

describe('Decompression', () => {
  it('Should throw if nothing is passed', () => 
    expect(() => lzo.decompress()).to.throw() );

  it('Should properly decompress and not throw', () =>
    expect( data.compare(lzo.decompress(compressed)) ).to.equal(0) );
});

describe('Properties', () => {
  it('Should have property \'version\'', () => 
    expect(lzo).to.have.ownProperty('version') );

  it('Should have property \'versionDate\'', () => 
    expect(lzo).to.have.ownProperty('versionDate') );

  it('Should have property \'errors\' (lzo error codes)', () =>
    expect(lzo).to.have.ownProperty('errors') );
});
@@ -99,14 +99,8 @@
 ('..
-/index
 ');%0A
@@ -132,59 +132,350 @@
 ct;%0A
-%0Alet data = crypto.randomBytes(100),%0A    compressed
+const sampleSize = parseInt(process.env.TEST_SAMPLE_SIZE, 10) %7C%7C 250;%0A%0Aconst run = plain =%3E lzo.decompress(lzo.compress(plain), plain.length).compare(plain);%0Aconst sum = (a, b) =%3E a + b;%0Aconst arr = len =%3E Array(len).fill(0).map((_, i) =%3E i);%0Aconst randChar = () =%3E String.fromCharCode(Math.random() * 1000);%0Aconst toBuf = a =%3E Buffer.from(a)
 ;%0A%0Ad
@@ -486,32 +486,46 @@
 ibe('Compression
+/Decompression
 ', () =%3E %7B%0A  it(
@@ -517,33 +517,46 @@
 , () =%3E %7B%0A  it('
-S
+lzo.compress s
 hould throw if n
@@ -598,24 +598,26 @@
 t(() =%3E lzo.
+de
 compress()).
@@ -641,46 +641,49 @@
 it('
-Should properly compress and not throw
+lzo.decompress throw if nothing is passed
 ', (
@@ -683,25 +683,24 @@
 sed', () =%3E 
-%7B
 %0A    expect(
@@ -708,34 +708,15 @@
 ) =%3E
- %7B%0A      compressed =
  lzo.
+de
 comp
@@ -724,121 +724,89 @@
 ess(
-data)%0A    %7D).to.not.throw();%0A  %7D);%0A%7D);%0A%0Adescribe('Decompression', () =%3E %7B%0A  it('Should throw if nothing is passed
+)).to.throw() );%0A%0A  it('Decompressed date should be the same as the initial input
 ', (
@@ -814,167 +814,248 @@
  =%3E 
+%7B
 %0A    
-expect(() =%3E lzo.decompress()).to.throw() );%0A%0A  it('Should properly decompress and not throw', () =%3E%0A    expect( data.compare(lzo.decompress(compressed)) 
+let random = arr(sampleSize).map(n =%3E crypto.randomBytes(n)),%0A        repetetive = arr(sampleSize).map(n =%3E randChar().repeat(n * 500)),%0A        result = random.concat(repetetive).map(toBuf).map(run).reduce(sum, 0);%0A%0A    expect(result
 ).to
@@ -1063,17 +1063,21 @@
 equal(0)
- 
+;%0A  %7D
 );%0A%7D);%0A%0A

Implement random generation of test data