youtube-cue/test/parser_test.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-06-07 20:47:10 +00:00
/*jshint esversion: 6 */
2017-06-07 20:14:09 +00:00
var assert = require('assert');
2018-06-02 11:00:34 +00:00
var parser = require('../src/parser');
2017-06-07 20:14:09 +00:00
const TEXT = `
2017-06-10 20:23:12 +00:00
00:40 The Coders - Hello World
2017-06-07 20:14:09 +00:00
12:23 This is not the end
Something else in the middle
1:23:11 Not the last song
2021-05-30 14:07:09 +00:00
01. Screens 0:00 - 5:40
02. Inharmonious Slog 5:40 - 10:11
03. The Everyday Push 10:11 - 15:46
04. Storm 15:46 - 19:07
05. Outre Lux 19:07 - 23:11
06. Balsam Massacre 23:11 - 26:24
07. Eco Friend 26:24 - 32:15
08. Off-Piste 32:15 - 36:53
09. Aura 36:53 - 41:44
10. Bombogenesis 41:44 - 48:20
2017-06-07 20:14:09 +00:00
`;
2017-06-07 20:47:10 +00:00
const TEXT_WITH_ARTIST = '12:23 Rolling Stones - Hello World';
2017-06-07 20:14:09 +00:00
describe('Parser', function() {
describe('parser', function() {
2021-05-30 14:07:09 +00:00
var big_result;
before(function() {
big_result = parser.parse(TEXT)
});
2017-06-07 20:14:09 +00:00
it('should find all timestamps', function() {
2021-05-30 14:07:09 +00:00
assert.equal(big_result.length, 13);
2017-06-07 20:14:09 +00:00
});
2017-06-07 20:47:10 +00:00
it('should find artist names', function() {
let result = parser.parse(TEXT_WITH_ARTIST);
assert.equal(result[0].artist, 'Rolling Stones');
});
2021-05-30 14:07:09 +00:00
it('should find track numbers', function() {
assert.equal(big_result[3].track, 1)
assert.equal(big_result[4].track, 2)
assert.equal(big_result[5].track, 3)
assert.equal(big_result[6].track, 4)
assert.equal(big_result[7].track, 5)
assert.equal(big_result[8].track, 6)
assert.equal(big_result[9].track, 7)
assert.equal(big_result[10].track, 8)
assert.equal(big_result[11].track, 9)
assert.equal(big_result[12].track, 10)
})
2017-06-07 20:14:09 +00:00
});
});