Permalink
Browse files

More test cases for buffers read()

  • Loading branch information...
nikhilm committed May 29, 2012
1 parent 9d08fb6 commit d3a20f9f316c43253e00fea5216da596c4618ab6
Showing with 37 additions and 0 deletions.
  1. +37 −0 spec/buffersSpec.js
View
@@ -63,4 +63,41 @@ vows.describe('taglib bindings: Buffers')
}
},
},
+
+ 'reading data from a buffer with unknown format': {
+ topic: function() {
+ var buf = fs.readFileSync(__dirname+'/sample.mp3');
+ Taglib.read(buf, '', this.callback);
+ },
+
+ 'should raise an error': function(err, _, _) {
+ assert.isNotNull(err);
+ assert.match(err.message, /Unknown file format/);
+ }
+ },
+
+ 'reading data from a buffer with wrong format': {
+ topic: function() {
+ var buf = fs.readFileSync(__dirname+'/sample.mp3');
+ Taglib.read(buf, 'ogg', this.callback);
+ },
+
+ 'should raise an error': function(err, _, _) {
+ assert.isNotNull(err);
+ assert.match(err.message, /Failed to extract tags/);
+ }
+ },
+
+ 'reading data from empty buffer': {
+ topic: function() {
+ var buf = new Buffer(0);
+ Taglib.read(buf, 'mpeg', this.callback);
+ },
+
+ 'should lead to empty tags and properties': function(err, tag, prop) {
+ assert.isNull(err);
+ assert.isEmpty(tag);
+ assert.isObject(prop);
+ }
+ }
}).export(module);

0 comments on commit d3a20f9

Please sign in to comment.