var test = require('tape');

var tst = require('../index');
var streams = require('./stream_fixtures');


test('single input', function(t) {
  var fixture = tst(t, new streams.TestObjectTransform());

  t.plan(1);

  fixture.deepEqual(
    {'foo': 'bar'},
    {'foo': 'bar'},
    'Given a single input the output matched',
    t.ok
  );
});

test('single input, bad ouput', function(t) {
  var fixture = tst(t, new streams.TestObjectTransform());

  t.plan(1);

  fixture.deepEqual(
    {'foo': 'bar'},
    {'foo': 'anything else'},
    'Input did not match output as expected',
    t.ifError
  );
});


test('multiple input', function(t) {
  var fixture = tst(t, new streams.TestObjectTransform());

  t.plan(1);

  fixture.deepEqual(
    [{'foo': 'bar'}, {'baz': 'qux'}],
    [{'foo': 'bar'}, {'baz': 'qux'}],
    'Given multiple inputs the outputs matched.',
    t.ok
  );
});


test('double output', function(t) {
  var fixture = tst(t, new streams.DoubleObjectTransform());

  t.plan(1);

  fixture.deepEqual(
    [{'foo': 'bar'}],
    [{'foo': 'bar'}, {'foo': 'bar'}],
    'For a single input we received two idential outputs',
    t.ok
  );
});


test('reverse string', function(t) {
  var fixture = tst(t, new streams.ReverseTransform()),
      matchString = 'one fish two fish';

  t.plan(1);

  fixture.deepEqual(
    matchString,
    matchString.split('').reverse().join(''),
    'Given a string the output matched the reverse of the string',
    t.ok
  );
});


test('reverse unicode string', function(t) {
  var fixture = tst(t, new streams.ReverseTransform()),
      matchString = 'Do you wanna build a ☃?';

  t.plan(1);

  fixture.deepEqual(
    matchString,
    matchString.split('').reverse().join(''),
    'Given a string with unicode characters the output matched the reverse of the string',
    t.ok
  );
});


test('reverse string - multiple async loop test cases', function(t) {
  var fixture = tst(t, new streams.ReverseTransform()),
      matchStrings = [
        'one fish two fish',
        'red fish blue fish',
        'black fish blue fish',
        'old fish new fish'
      ];

  t.plan(matchStrings.length);

  matchStrings.forEach(function(matchString) {
    fixture.deepEqual(
      matchString,
      matchString.split('').reverse().join(''),
      'Given a string the output matched the reverse of the string',
      t.ok
    );
  });
});


test('reverse string - multiple async test cases', function(t) {
  var fixture = tst(t, new streams.ReverseTransform()),
      matchString1 = 'one fish two fish',
      matchString2 = 'red fish blue fish',
      matchString3 = 'black fish blue fish',
      matchString4 = 'old fish new fish';

  t.plan(4);

  fixture.deepEqual(
    matchString1,
    matchString1.split('').reverse().join(''),
    'Given a string the output matched the reverse of the string',
    t.ok
  );

  fixture.deepEqual(
    matchString2,
    matchString2.split('').reverse().join(''),
    'Given a string the output matched the reverse of the string',
    t.ok
  );

  fixture.deepEqual(
    matchString3,
    matchString3.split('').reverse().join(''),
    'Given a string the output matched the reverse of the string',
    t.ok
  );

  fixture.deepEqual(
    matchString4,
    matchString4.split('').reverse().join(''),
    'Given a string the output matched the reverse of the string',
    t.ok
  );
});


test('reverse string - no output expected but output received', function(t) {
  var fixture = tst(t, new streams.ReverseTransform());

  t.plan(1);

  fixture.deepEqual('foo', null, 'Given a string we got no output as expected', t.ifError);
});


test('blackhole - no output expected', function(t) {
  var fixture = tst(t, new streams.BlackholeTransform());

  t.plan(1);

  fixture.deepEqual('foo', [], 'Given a string we got no output as expected', t.ok, 100);
});


test('blackhole - no output expected with null output', function(t) {
  var fixture = tst(t, new streams.BlackholeTransform());

  t.plan(1);

  fixture.deepEqual('foo', null, 'Given a string we got no output as expected', t.ok, 100);
});

@@ -3595,32 +3595,296 @@
 ifError);%0A%7D);%0A%0A%0A
+test('reverse string - array of input values', function(t) %7B%0A  var fixture = tst(t, new streams.ReverseTransform());%0A%0A  t.plan(1);%0A%0A  fixture.deepEqual(%0A    %5B'foo', 'bar'%5D,%0A    %5B'oof', 'rab'%5D,%0A    'Given a string we got no output as expected',%0A    t.ok%0A  );%0A%7D);%0A%0A%0A
 test('blackhole 

Add test for an array of input strings.