Add an m3u parsing test

This commit is contained in:
Jordan Eldredge 2018-10-24 23:27:48 -07:00
parent 3032ccdbc3
commit 71d6466bf6
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,7 @@
#EXTM3U
#EXTINF:168,01 Ghosts I.mp3
test/01%20Ghosts%20I.mp3
#EXTINF:196,02 Ghosts I.mp3
test/02%20Ghosts%20I.mp3
#EXTINF:230,03 Ghosts I.mp3
test/03%20Ghosts%20I.mp3

30
js/m3uParser.test.js Normal file
View file

@ -0,0 +1,30 @@
import fs from "fs";
import path from "path";
import m3uParser from "./m3uParser";
test("Can parse a sample m3u file", () => {
const content = fs.readFileSync(
path.join(__dirname, "__tests__/fixtures/sample.m3u"),
"utf8"
);
expect(m3uParser(content)).toMatchInlineSnapshot(`
Array [
Object {
"duration": 168,
"file": "test/01%20Ghosts%20I.mp3",
"title": "01 Ghosts I.mp3",
},
Object {
"duration": 196,
"file": "test/02%20Ghosts%20I.mp3",
"title": "02 Ghosts I.mp3",
},
Object {
"duration": 230,
"file": "test/03%20Ghosts%20I.mp3",
"title": "03 Ghosts I.mp3",
},
]
`);
});