diff --git a/test/samples/incomplete.mp3 b/test/samples/incomplete.mp3 new file mode 100644 index 000000000..73ea83a50 Binary files /dev/null and b/test/samples/incomplete.mp3 differ diff --git a/test/test-id3v1.1.ts b/test/test-id3v1.1.ts index d14aea8f7..b0a2bab4b 100644 --- a/test/test-id3v1.1.ts +++ b/test/test-id3v1.1.ts @@ -132,5 +132,4 @@ describe("Parsing MPEG / ID3v1", () => { }); }); - }); diff --git a/test/test-mp3.ts b/test/test-mp3.ts index 10ee0af4c..361392601 100644 --- a/test/test-mp3.ts +++ b/test/test-mp3.ts @@ -24,4 +24,28 @@ describe("Parse MP3 files", () => { }); }); + describe("should handle incomplete MP3 file", () => { + + const filePath = path.join(__dirname, 'samples', "incomplete.mp3"); + + function checkFormat(format: mm.IFormat) { + t.deepEqual(format.tagTypes, ['ID3v2.3', 'ID3v1.1'], 'format.tagTypes'); + t.strictEqual(format.duration, 4349.6751020408165, 'format.duration'); + t.strictEqual(format.dataformat, 'mp3', 'format.dataformat'); + t.strictEqual(format.lossless, false, 'format.lossless'); + t.strictEqual(format.sampleRate, 22050, 'format.sampleRate = 44.1 kHz'); + t.strictEqual(format.bitrate, 64000, 'format.bitrate = 128 kbit/sec'); + t.strictEqual(format.numberOfChannels, 2, 'format.numberOfChannels 2 (stereo)'); + } + + it("should decode from a file", () => { + + return mm.parseFile(filePath).then(metadata => { + for (const tagType in metadata.native) + throw new Error("Do not expect any native tag type, got: " + tagType); + checkFormat(metadata.format); + }); + }); + }); + });