mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-27 03:54:24 +00:00
Add an m3u parsing test
This commit is contained in:
parent
3032ccdbc3
commit
71d6466bf6
2 changed files with 37 additions and 0 deletions
7
js/__tests__/fixtures/sample.m3u
Executable file
7
js/__tests__/fixtures/sample.m3u
Executable 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
30
js/m3uParser.test.js
Normal 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",
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue