🏡 index : github.com/captn3m0/youtube-cue.git

author Nemo <commits@captnemo.in> 2021-06-28 14:26:58.0 +05:30:00
committer Nemo <commits@captnemo.in> 2021-06-28 14:26:58.0 +05:30:00
commit
4b5c16d699ffa34d23a99851ecd9f4ce54edc838 [patch]
tree
f730c748c2938a9d9f81d84d11cad9d8b4d42556
parent
f00efc7806cd1e228676e2d4e121ab29f25df551
download
4b5c16d699ffa34d23a99851ecd9f4ce54edc838.tar.gz

broken test for #64



Diff

 test/parser_test.js | 243 ++++++++++++++++++++++++++++++++++++++++++++------------------------------------
 1 file changed, 131 insertions(+), 112 deletions(-)

diff --git a/test/parser_test.js b/test/parser_test.js
index 3977aab..b4c3c12 100644
--- a/test/parser_test.js
+++ a/test/parser_test.js
@@ -1,7 +1,7 @@
/*jshint esversion: 6 */
import { strict as assert } from 'assert';
import { strict as assert } from "assert";

import {parse} from '../src/parser.js'
import { parse } from "../src/parser.js";

const TEXT = `
00:40 The Coders - Hello World
@@ -22,42 +22,61 @@
50:23 Bye World
`;

const TEXT_WITH_ARTIST = '12:23 Rolling Stones - Hello World';
const TEXT_WITH_ARTIST = "12:23 Rolling Stones - Hello World";

describe('Parser', function() {
describe("Parser", function() {
  var big_result;
  before(function() {
    big_result = parse(TEXT)
    big_result = parse(TEXT);
  });
  it('should find all timestamps', function() {
  it("should find all timestamps", function() {
    assert.equal(big_result.length, 15);
  });

  it('should find artist names', function() {
  it("should find artist names", function() {
    let result = parse(TEXT_WITH_ARTIST);
    assert.equal(result[0].artist, 'Rolling Stones');
    assert.equal(result[0].artist, "Rolling Stones");
  });

  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)
  })
  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);
  });

  it('should ensure ending timestamps for all', function() {
    assert.deepEqual(big_result[13].end, {calc: 3023, hh:0, mm:50, ss:23, ts: '00:50:23'})
  it("should ensure ending timestamps for all", function() {
    assert.deepEqual(big_result[13].end, {
      calc: 3023,
      hh: 0,
      mm: 50,
      ss: 23,
      ts: "00:50:23",
    });
    // TODO
    assert.deepEqual(big_result[14].end, null)
  })
    assert.deepEqual(big_result[14].end, null);
  });

  it("should parse timestamps with square brackets", function() {
    let result = parse(`[00:00:00] 1. Steve Kroeger x Skye Holland - Through The Dark
      [00:02:53] 2. Gabri Ponte x Jerome - Lonely `)
    assert.deepEqual(result[0], {
        artist: "Steve Kroeger x Skye Holland",
        title: "Through The Dark",
        track: 1,
        start: { ts: "00:00:00", hh: 0, mm: 0, ss: 0, calc: 0 },
        end: { ts: "00:02:53", hh: 0, mm: 2, ss: 53, calc: 173 },
        _: { left_text: "", right_text: "Steve Kroeger x Skye Holland - Through The Dark" },
      })
  });

  it('should parse taylor swift', function() {
  it("should parse taylor swift", function() {
    let result = parse(`0:00 the 1
    3:29 cardigan
    9:30 the last great american dynasty
@@ -74,145 +93,145 @@
    52:17 betty
    57:15 peace
    1:01:10 hoax
    1:04:50 the lakes`)
    1:04:50 the lakes`);

    assert.deepEqual(result, [
      {
        artist: 'Unknown',
        title: 'the 1',
        artist: "Unknown",
        title: "the 1",
        track: 1,
        start: { ts: '00:0:00', hh: 0, mm: 0, ss: 0, calc: 0 },
        end: { ts: '00:3:29', hh: 0, mm: 3, ss: 29, calc: 209 },
        _: { left_text: '', right_text: 'the 1' }
        start: { ts: "00:0:00", hh: 0, mm: 0, ss: 0, calc: 0 },
        end: { ts: "00:3:29", hh: 0, mm: 3, ss: 29, calc: 209 },
        _: { left_text: "", right_text: "the 1" },
      },
      {
        artist: 'Unknown',
        title: 'cardigan',
        artist: "Unknown",
        title: "cardigan",
        track: 2,
        start: { ts: '00:3:29', hh: 0, mm: 3, ss: 29, calc: 209 },
        end: { ts: '00:9:30', hh: 0, mm: 9, ss: 30, calc: 570 },
        _: { left_text: '', right_text: 'cardigan' }
        start: { ts: "00:3:29", hh: 0, mm: 3, ss: 29, calc: 209 },
        end: { ts: "00:9:30", hh: 0, mm: 9, ss: 30, calc: 570 },
        _: { left_text: "", right_text: "cardigan" },
      },
      {
        artist: 'Unknown',
        title: 'the last great american dynasty',
        artist: "Unknown",
        title: "the last great american dynasty",
        track: 3,
        start: { ts: '00:9:30', hh: 0, mm: 9, ss: 30, calc: 570 },
        end: { ts: '00:11:56', hh: 0, mm: 11, ss: 56, calc: 716 },
        _: { left_text: '', right_text: 'the last great american dynasty' }
        start: { ts: "00:9:30", hh: 0, mm: 9, ss: 30, calc: 570 },
        end: { ts: "00:11:56", hh: 0, mm: 11, ss: 56, calc: 716 },
        _: { left_text: "", right_text: "the last great american dynasty" },
      },
      {
        artist: 'Unknown',
        title: 'exile',
        artist: "Unknown",
        title: "exile",
        track: 4,
        start: { ts: '00:11:56', hh: 0, mm: 11, ss: 56, calc: 716 },
        end: { ts: '00:16:46', hh: 0, mm: 16, ss: 46, calc: 1006 },
        _: { left_text: '', right_text: 'exile' }
        start: { ts: "00:11:56", hh: 0, mm: 11, ss: 56, calc: 716 },
        end: { ts: "00:16:46", hh: 0, mm: 16, ss: 46, calc: 1006 },
        _: { left_text: "", right_text: "exile" },
      },
      {
        artist: 'Unknown',
        title: 'my tears ricochet',
        artist: "Unknown",
        title: "my tears ricochet",
        track: 5,
        start: { ts: '00:16:46', hh: 0, mm: 16, ss: 46, calc: 1006 },
        end: { ts: '00:21:03', hh: 0, mm: 21, ss: 3, calc: 1263 },
        _: { left_text: '', right_text: 'my tears ricochet' }
        start: { ts: "00:16:46", hh: 0, mm: 16, ss: 46, calc: 1006 },
        end: { ts: "00:21:03", hh: 0, mm: 21, ss: 3, calc: 1263 },
        _: { left_text: "", right_text: "my tears ricochet" },
      },
      {
        artist: 'Unknown',
        title: 'mirrorball',
        artist: "Unknown",
        title: "mirrorball",
        track: 6,
        start: { ts: '00:21:03', hh: 0, mm: 21, ss: 3, calc: 1263 },
        end: { ts: '00:24:35', hh: 0, mm: 24, ss: 35, calc: 1475 },
        _: { left_text: '', right_text: 'mirrorball' }
        start: { ts: "00:21:03", hh: 0, mm: 21, ss: 3, calc: 1263 },
        end: { ts: "00:24:35", hh: 0, mm: 24, ss: 35, calc: 1475 },
        _: { left_text: "", right_text: "mirrorball" },
      },
      {
        artist: 'Unknown',
        title: 'seven',
        artist: "Unknown",
        title: "seven",
        track: 7,
        start: { ts: '00:24:35', hh: 0, mm: 24, ss: 35, calc: 1475 },
        end: { ts: '00:28:07', hh: 0, mm: 28, ss: 7, calc: 1687 },
        _: { left_text: '', right_text: 'seven' }
        start: { ts: "00:24:35", hh: 0, mm: 24, ss: 35, calc: 1475 },
        end: { ts: "00:28:07", hh: 0, mm: 28, ss: 7, calc: 1687 },
        _: { left_text: "", right_text: "seven" },
      },
      {
        artist: 'Unknown',
        title: 'august',
        artist: "Unknown",
        title: "august",
        track: 8,
        start: { ts: '00:28:07', hh: 0, mm: 28, ss: 7, calc: 1687 },
        end: { ts: '00:32:30', hh: 0, mm: 32, ss: 30, calc: 1950 },
        _: { left_text: '', right_text: 'august' }
        start: { ts: "00:28:07", hh: 0, mm: 28, ss: 7, calc: 1687 },
        end: { ts: "00:32:30", hh: 0, mm: 32, ss: 30, calc: 1950 },
        _: { left_text: "", right_text: "august" },
      },
      {
        artist: 'Unknown',
        title: 'this is me trying',
        artist: "Unknown",
        title: "this is me trying",
        track: 9,
        start: { ts: '00:32:30', hh: 0, mm: 32, ss: 30, calc: 1950 },
        end: { ts: '00:35:52', hh: 0, mm: 35, ss: 52, calc: 2152 },
        _: { left_text: '', right_text: 'this is me trying' }
        start: { ts: "00:32:30", hh: 0, mm: 32, ss: 30, calc: 1950 },
        end: { ts: "00:35:52", hh: 0, mm: 35, ss: 52, calc: 2152 },
        _: { left_text: "", right_text: "this is me trying" },
      },
      {
        artist: 'Unknown',
        title: 'illicit affairs',
        artist: "Unknown",
        title: "illicit affairs",
        track: 10,
        start: { ts: '00:35:52', hh: 0, mm: 35, ss: 52, calc: 2152 },
        end: { ts: '00:39:05', hh: 0, mm: 39, ss: 5, calc: 2345 },
        _: { left_text: '', right_text: 'illicit affairs' }
        start: { ts: "00:35:52", hh: 0, mm: 35, ss: 52, calc: 2152 },
        end: { ts: "00:39:05", hh: 0, mm: 39, ss: 5, calc: 2345 },
        _: { left_text: "", right_text: "illicit affairs" },
      },
      {
        artist: 'Unknown',
        title: 'invisible strings',
        artist: "Unknown",
        title: "invisible strings",
        track: 11,
        start: { ts: '00:39:05', hh: 0, mm: 39, ss: 5, calc: 2345 },
        end: { ts: '00:43:22', hh: 0, mm: 43, ss: 22, calc: 2602 },
        _: { left_text: '', right_text: 'invisible strings' }
        start: { ts: "00:39:05", hh: 0, mm: 39, ss: 5, calc: 2345 },
        end: { ts: "00:43:22", hh: 0, mm: 43, ss: 22, calc: 2602 },
        _: { left_text: "", right_text: "invisible strings" },
      },
      {
        artist: 'Unknown',
        title: 'mad woman',
        artist: "Unknown",
        title: "mad woman",
        track: 12,
        start: { ts: '00:43:22', hh: 0, mm: 43, ss: 22, calc: 2602 },
        end: { ts: '00:49:30', hh: 0, mm: 49, ss: 30, calc: 2970 },
        _: { left_text: '', right_text: 'mad woman' }
        start: { ts: "00:43:22", hh: 0, mm: 43, ss: 22, calc: 2602 },
        end: { ts: "00:49:30", hh: 0, mm: 49, ss: 30, calc: 2970 },
        _: { left_text: "", right_text: "mad woman" },
      },
      {
        artist: 'Unknown',
        title: 'epiphany',
        artist: "Unknown",
        title: "epiphany",
        track: 13,
        start: { ts: '00:49:30', hh: 0, mm: 49, ss: 30, calc: 2970 },
        end: { ts: '00:52:17', hh: 0, mm: 52, ss: 17, calc: 3137 },
        _: { left_text: '', right_text: 'epiphany' }
        start: { ts: "00:49:30", hh: 0, mm: 49, ss: 30, calc: 2970 },
        end: { ts: "00:52:17", hh: 0, mm: 52, ss: 17, calc: 3137 },
        _: { left_text: "", right_text: "epiphany" },
      },
      {
        artist: 'Unknown',
        title: 'betty',
        artist: "Unknown",
        title: "betty",
        track: 14,
        start: { ts: '00:52:17', hh: 0, mm: 52, ss: 17, calc: 3137 },
        end: { ts: '00:57:15', hh: 0, mm: 57, ss: 15, calc: 3435 },
        _: { left_text: '', right_text: 'betty' }
        start: { ts: "00:52:17", hh: 0, mm: 52, ss: 17, calc: 3137 },
        end: { ts: "00:57:15", hh: 0, mm: 57, ss: 15, calc: 3435 },
        _: { left_text: "", right_text: "betty" },
      },
      {
        artist: 'Unknown',
        title: 'peace',
        artist: "Unknown",
        title: "peace",
        track: 15,
        start: { ts: '00:57:15', hh: 0, mm: 57, ss: 15, calc: 3435 },
        end: { ts: '1:01:10', hh: 1, mm: 1, ss: 10, calc: 3670 },
        _: { left_text: '', right_text: 'peace' }
        start: { ts: "00:57:15", hh: 0, mm: 57, ss: 15, calc: 3435 },
        end: { ts: "1:01:10", hh: 1, mm: 1, ss: 10, calc: 3670 },
        _: { left_text: "", right_text: "peace" },
      },
      {
        artist: 'Unknown',
        title: 'hoax',
        artist: "Unknown",
        title: "hoax",
        track: 16,
        start: { ts: '1:01:10', hh: 1, mm: 1, ss: 10, calc: 3670 },
        end: { ts: '1:04:50', hh: 1, mm: 4, ss: 50, calc: 3890 },
        _: { left_text: '', right_text: 'hoax' }
        start: { ts: "1:01:10", hh: 1, mm: 1, ss: 10, calc: 3670 },
        end: { ts: "1:04:50", hh: 1, mm: 4, ss: 50, calc: 3890 },
        _: { left_text: "", right_text: "hoax" },
      },
      {
        artist: 'Unknown',
        title: 'the lakes',
        artist: "Unknown",
        title: "the lakes",
        track: 17,
        start: { ts: '1:04:50', hh: 1, mm: 4, ss: 50, calc: 3890 },
        start: { ts: "1:04:50", hh: 1, mm: 4, ss: 50, calc: 3890 },
        end: null,
        _: { left_text: '', right_text: 'the lakes' }
      }
        _: { left_text: "", right_text: "the lakes" },
      },
    ]);
  })
  });
});