Skip to content

Commit

Permalink
Changed audio-frame-header-bug test file into test-code-file for gene…
Browse files Browse the repository at this point in the history
…ric MP3 parsing tests.

Related to #64
  • Loading branch information
Borewit committed Mar 9, 2018
1 parent 0389afb commit e7c78fb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test-mp3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {} from "mocha";
import {assert} from 'chai';
import * as mm from '../src';
import * as path from 'path';

const t = assert;

describe("Parse MP3 files", () => {

it("should handle audio-frame-header-bug", function() {

this.timeout(15000); // It takes a long time to parse

const filePath = path.join(__dirname, 'samples', 'audio-frame-header-bug.mp3');

return mm.parseFile(filePath, {duration: true}).then(result => {
// FooBar: 3:20.556 (8.844.527 samples); 44100 Hz => 200.5561678004535 seconds
// t.strictEqual(result.format.duration, 200.59591666666665); // previous
// t.strictEqual(result.format.duration, 200.5561678004535); // FooBar

// If MPEG Layer II is accepted, it will give back third frame with a different frame length;
// therefore it start counting actual parsable frames ending up on ~66.86
t.strictEqual(result.format.duration, 66.8647619047619);
});
});

});

0 comments on commit e7c78fb

Please sign in to comment.