Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit test to read incomplete mp3 file; added incomplete mp3 file. #64

Merged
merged 3 commits into from
Mar 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added test/samples/incomplete.mp3
Binary file not shown.
1 change: 0 additions & 1 deletion test/test-id3v1.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,4 @@ describe("Parsing MPEG / ID3v1", () => {
});

});

});
24 changes: 24 additions & 0 deletions test/test-mp3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

});