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

describe('filter plugin: 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();
    });
  });
});

@@ -111,16 +111,68 @@
 tion()%7B%0A
+  describe('Passed simple condition', function()%7B%0A  
   it('sh
@@ -229,32 +229,34 @@
 tion(done)%7B%0A    
+  
 condition.filter
@@ -290,32 +290,34 @@
 ion(err, word)%7B%0A
+  
       word.shoul
@@ -328,32 +328,34 @@
 ual(%221%22);%0A      
+  
 done();%0A    %7D);%0A
@@ -346,35 +346,41 @@
 done();%0A    
+  
 %7D);%0A
+  
   %7D);%0A%0A
+  
   it('should
@@ -432,32 +432,34 @@
 function(done)%7B%0A
+  
     condition.fi
@@ -520,32 +520,34 @@
 r, word)%7B%0A      
+ 
+ 
 word.should.equa
@@ -558,32 +558,34 @@
 ey%22);%0A      
+  
 done();%0A
     %7D);%0A  %7D)
@@ -568,32 +568,34 @@
     done();%0A
+  
     %7D);%0A
   %7D);%0A%0A  it(
@@ -574,39 +574,43 @@
 ne();%0A      %7D);%0A
+  
   %7D);%0A%0A
+  
   it('should out
@@ -658,32 +658,34 @@
 function(done)%7B%0A
+  
     condition.fi
@@ -762,24 +762,26 @@
 ord)%7B%0A      
+  
 word.should.
@@ -801,32 +801,34 @@
 :1%22);%0A      
+  
 done();%0A
     %7D);%0A  %7D)
@@ -811,32 +811,34 @@
     done();%0A
+  
     %7D);%0A
   %7D);%0A%0A  it(
@@ -821,31 +821,35 @@
 ;%0A      %7D);%0A
+  
   %7D);%0A%0A
+  
   it('should
@@ -902,32 +902,34 @@
 tion(done)%7B%0A    
+ 
+ 
 condition.filter
@@ -994,16 +994,18 @@
 %7B%0A      
+  
 var shou
@@ -1041,16 +1041,18 @@
 ;%0A      
+  
 should.e
@@ -1071,32 +1071,34 @@
 ull);%0A      
+ 
+ 
 done();%0A
     %7D);%0A  %7D)
@@ -1081,32 +1081,34 @@
     done();%0A
+  
     %7D);%0A
   %7D);%0A%0A  it(
@@ -1091,24 +1091,26 @@
 ;%0A      %7D);%0A
+  
   %7D);%0A%0A  it(
@@ -1106,16 +1106,18 @@
  %7D);%0A%0A  
+ 
+ 
 it('rase
@@ -1161,24 +1161,26 @@
 tion(done)%7B%0A
+  
     conditio
@@ -1238,16 +1238,18 @@
 %7B%0A      
+  
 err.shou
@@ -1262,32 +1262,34 @@
 true;%0A      
+ 
+ 
 done();%0A
     %7D);%0A  %7D)
@@ -1272,24 +1272,625 @@
     done();%0A
+      %7D);%0A    %7D);%0A  %7D);%0A%0A  describe('Passed same conditions', function()%7B%0A    it('should output static message if match last condition.', function(done)%7B%0A      condition.filter(%5B%7B'rule': '%3E=5', 'format': 'foo'%7D, %7B'rule': '%3C5', 'format': 'bar'%7D%5D, %221%22, function(err, word)%7B%0A        word.should.equal(%22bar%22);%0A        done();%0A      %7D);%0A    %7D);%0A%0A    it('should output static message if match first condition.', function(done)%7B%0A      condition.filter(%5B%7B'rule': '%3E=5', 'format': 'foo'%7D, %7B'rule': '%3C5', 'format': 'bar'%7D%5D, %2210%22, function(err, word)%7B%0A        word.should.equal(%22foo%22);%0A        done();%0A      %7D);%0A
     %7D);%0A  %7D)
@@ -1891,12 +1891,13 @@
 ;%0A  %7D);%0A
+%0A
 %7D);%0A

テスト追加 条件を複数した場合のケース追加