Skip to content
Browse files

added broken test to demonstrate malformed pcap file should emit error

  • Loading branch information...
1 parent af69cf2 commit ac8cf5a9c5d9132a491aa269c5e81dc697c4116a @joeferner joeferner committed Jan 11, 2012
Showing with 16 additions and 0 deletions.
  1. +1 −0 test/malformed.pcap
  2. +15 −0 test/{pcap-parser.js → pcap-parser-test.js}
View
1 test/malformed.pcap
@@ -0,0 +1 @@
+this is not a valid pcap file.
View
15 test/pcap-parser.js → test/pcap-parser-test.js
@@ -5,6 +5,21 @@ var path = require('path');
var pcapp = require('../index.js');
vows.describe('pcap-parser').addBatch({
+ 'given a bad/malformed pcap file get an error': {
+ topic: new pcapp.Parser(fs.createReadStream(path.join(__dirname, 'malformed.pcap'))),
+
+ 'the parser should emit error event': {
+ topic: function(parser) {
+ parser.once('error', this.callback);
+ parser.parse();
+ },
+
+ 'error should have been called': function(err) {
+ assert.isNotNull(err);
+ }
+ }
+ },
+
'given a readable stream of a pcap file': {
topic: new pcapp.Parser(fs.createReadStream(path.join(__dirname, 'smtp.pcap'))),

0 comments on commit ac8cf5a

Please sign in to comment.
Something went wrong with that request. Please try again.