Skip to content

Commit

Permalink
yara tests working.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjay committed Nov 20, 2013
1 parent 52f1ad1 commit 13f33a4
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/spec/yara.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Created by mattjohansen on 11/19/13.
*/

var yara = require('../scripts/yara.coffee');

describe('reputation', function() {
var robot = null;

beforeEach(function(){
robot = {
respond: function(regex, callback){},
}
spyOn(robot, 'respond');

yara(robot);
});

it('should be a function', function(){
expect(typeof(yara)).toBe('function');
});

it('should respond correctly when passed an IP', function() {
var msg = {
match: 'yara template'.match(robot.respond.calls[0].args[0]),
send: function() {}
}
spyOn(msg, 'send');

expect(robot.respond).toHaveBeenCalled();
robot.respond.calls[0].args[1](msg);
expect(msg.send).toHaveBeenCalled();
expect(msg.send.mostRecentCall.args[0]).toBeDefined();
});

it('should not call anything if the regex doesnt match', function() {
var msg = {
match: 'reputation url www.google.com'.match(robot.respond.mostRecentCall.args[0]),
send: function() {}
}
spyOn(msg, 'send');

expect(robot.respond).toHaveBeenCalled();
expect(msg.send).not.toHaveBeenCalled();
});

});

0 comments on commit 13f33a4

Please sign in to comment.