From 13f33a4b843ca116054c9d3c2735d64e775ad7c4 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Nov 2013 22:55:38 -0600 Subject: [PATCH] yara tests working. --- src/spec/yara.spec.js | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/spec/yara.spec.js diff --git a/src/spec/yara.spec.js b/src/spec/yara.spec.js new file mode 100644 index 0000000..4bcde4a --- /dev/null +++ b/src/spec/yara.spec.js @@ -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(); + }); + +}); \ No newline at end of file