Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test cases for buffer tagSync

  • Loading branch information...
commit 3264ffaadca37ad36061f898d064ba835ad91606 1 parent d3a20f9
@nikhilm authored
Showing with 64 additions and 0 deletions.
  1. +64 −0 spec/buffersSpec.js
View
64 spec/buffersSpec.js
@@ -99,5 +99,69 @@ vows.describe('taglib bindings: Buffers')
assert.isEmpty(tag);
assert.isObject(prop);
}
+ },
+
+ /* * T A G S Y N C * */
+ 'tagSync metadata from mp3 buffer': {
+ topic: function() {
+ var buf = fs.readFileSync(__dirname+'/sample.mp3');
+ return Taglib.tagSync(buf, 'mpeg');
+ },
+
+ 'title should be `A bit-bucket full of tags`': function (tag) {
+ assert.equal(tag.title, 'A bit-bucket full of tags');
+ },
+ 'artist should be by `gitzer\'s`': function (tag) {
+ assert.equal(tag.artist, 'gitzer\'s');
+ },
+ 'album should be on `Waffles for free!`': function (tag) {
+ assert.equal(tag.album, "Waffles for free!");
+ },
+ 'track should be the first': function (tag) {
+ assert.equal(tag.track, 1);
+ },
+ 'should be from 2011': function (tag) {
+ assert.equal(tag.year, 2011);
+ },
+ 'should have a silly comment': function(tag) {
+ assert.equal(tag.comment, "Salami Wiglet.");
+ }
+ },
+
+ 'tagSync data from a buffer with unknown format': {
+ topic: function() {
+ return function() {
+ var buf = fs.readFileSync(__dirname+'/sample.mp3');
+ return Taglib.tagSync(buf, '', this.callback);
+ }
+ },
+
+ 'should raise an error': function(topic) {
+ assert.throws(topic, /Unknown file format/);
+ }
+ },
+
+ 'tagSync data from a buffer with wrong format': {
+ topic: function() {
+ return function() {
+ var buf = fs.readFileSync(__dirname+'/sample.mp3');
+ return Taglib.tagSync(buf, 'ogg');
+ }
+ },
+
+ 'should raise an error': function(topic) {
+ assert.throws(topic, /Failed to extract tags/);
+ }
+ },
+
+ 'tagSync data from empty buffer': {
+ topic: function() {
+ var buf = new Buffer(0);
+ return Taglib.tagSync(buf, 'mpeg');
+ },
+
+ 'should lead to empty tags': function(tag) {
+ assert.isObject(tag);
+ }
}
}).export(module);
Please sign in to comment.
Something went wrong with that request. Please try again.