var condition = require('../../../lib/plugin/filter/condition.js');

describe('filter plugin: condition', function(){
  describe('Passed simple condition', function(){
    it('should throuw input value if match condition.', function(done){
      condition.filter({'rule': '<5'}, "1", function(err, word){
        word.should.equal("1");
        done();
      });
    });

    it('should output static message if match condition.', function(done){
      condition.filter({'rule': '<5', 'format': 'hey'}, "1", function(err, word){
        word.should.equal("hey");
        done();
      });
    });

    it('should output format message if match condition.', function(done){
      condition.filter({'rule': '<5', 'format': 'OUTPUT:__word__'}, "1", function(err, word){
        word.should.equal("OUTPUT:1");
        done();
      });
    });

    it('should output is null if not match condition.', function(done){
      condition.filter({'rule': '>5', 'format': 'hey'}, "1", function(err, word){
        var should = require('chai').should();
        should.equal(word, null);
        done();
      });
    });

    it('rase error if passed invalid rule.', function(done){
      condition.filter({'rule': 'hoge'}, "1", function(err, word){
        err.should.be.true;
        done();
      });
    });
  });

  describe('Passed same conditions', function(){
    it('should output static message if match last condition.', function(done){
      condition.filter([{'rule': '>=5', 'format': 'foo'}, {'rule': '<5', 'format': 'bar'}], "1", function(err, word){
        word.should.equal("bar");
        done();
      });
    });

    it('should output static message if match first condition.', function(done){
      condition.filter([{'rule': '>=5', 'format': 'foo'}, {'rule': '<5', 'format': 'bar'}], "10", function(err, word){
        word.should.equal("foo");
        done();
      });
    });
  });

});

@@ -189,16 +189,24 @@
 w input 
+numeric 
 value if
@@ -365,32 +365,256 @@
    %7D);%0A    %7D);%0A%0A
+    it('should throuw input string value if match condition.', function(done)%7B%0A      condition.filter(%7B'rule': '.length %3C 5'%7D, %22abc%22, function(err, word)%7B%0A        word.should.equal(%22abc%22);%0A        done();%0A      %7D);%0A    %7D);%0A%0A
     it('should o

Add implementation for string values condition.