Skip to content

Commit

Permalink
Updated test cases for multiple instances of Lyrics()
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-deng committed Mar 27, 2018
1 parent 1df75d8 commit cf000cb
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lyrics.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lyrics.js",
"version": "0.3.5",
"version": "0.4.0",
"description": "A JavaScript for parsing LRC file and synchronize lyrics.",
"main": "",
"directories": {
Expand Down
30 changes: 30 additions & 0 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,35 @@
[03:15.430][04:30.500][04:48.410]
[04:18.670]だってだって、いまが最高!
[04:37.410]Ah! 光を追いかけてきたんだよ…</script>
<script id='sample_complex_chinese' type='text/plain'>[00:27.540][04:31.520]Ah!由微小的预感拉开序幕
[00:32.970]Ah!希望在星空中穿梭
[00:38.450]像花朵绽放般的笑容
[00:43.920]一如既往的友情的笑容
[00:49.160]
[00:49.510]无法忘记 一直不会忘记
[00:54.940]我们的心这样连在一起
[01:00.410]见证这个世界上的快乐并为之歌唱
[01:09.940]直到最后(我们合而为一)
[01:16.660]
[01:17.040][03:37.800]小鸟的翅膀终于变得丰满
[01:25.010][03:45.640]展翅高飞踏上旅程
[01:28.130][03:48.760]暖色的海洋不断地延伸
[01:36.050][03:56.730]恍若曾几何时梦中描绘的景色
[01:40.300][04:00.990]此时感到有些伤感,是否要将时光倒转?
[01:52.490][04:13.240]No No No 现在是最好的时刻!
[01:58.620][02:42.890]
[02:20.460]与大家相遇相识让我非常开心
[02:27.090]我真的不想和大家分离
[02:31.550]我们不需要眼泪 就这么走下去吧
[02:36.980]挥挥手,再挥挥手
[02:45.370]正因为我们如此努力地追逐着光芒
[02:53.190]所以无需再说什么分别
[02:56.320]再度相会的时候,你是否还能喊出我的名字?
[03:04.320]在美好的未来中 我们紧紧相连的梦想
[03:08.560]你和我的Live and Life
[03:15.430][04:30.500][04:48.410]
[04:18.670]因为此时此刻就是最好的!
[04:37.410]Ah!我们一起追逐着那道光芒</script>
<script id='abnormal' type='text/plain'>[ar:Artist]
[ti:Title]
[00:j7.540]alskdfjlasdkjflsakdjf
Expand Down Expand Up @@ -127,6 +156,7 @@
<script>
sample = document.getElementById('sample').innerHTML;
sample_complex = document.getElementById('sample_complex').innerHTML;
sample_complex_chinese = document.getElementById('sample_complex_chinese').innerHTML;
abnormal = document.getElementById('abnormal').innerHTML;
id_tags_only = document.getElementById('id_tags_only').innerHTML;
id_tags_lyrics = document.getElementById('id_tags_lyrics').innerHTML;
Expand Down
30 changes: 30 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,36 @@ sample_complex = `[00:27.540][04:31.520]Ah! ほのかな予感から始まり
[04:18.670]だってだって、いまが最高!
[04:37.410]Ah! 光を追いかけてきたんだよ…
`
sample_complex_chinese = `[00:27.540][04:31.520]Ah!由微小的预感拉开序幕
[00:32.970]Ah!希望在星空中穿梭
[00:38.450]像花朵绽放般的笑容
[00:43.920]一如既往的友情的笑容
[00:49.160]
[00:49.510]无法忘记 一直不会忘记
[00:54.940]我们的心这样连在一起
[01:00.410]见证这个世界上的快乐并为之歌唱
[01:09.940]直到最后(我们合而为一)
[01:16.660]
[01:17.040][03:37.800]小鸟的翅膀终于变得丰满
[01:25.010][03:45.640]展翅高飞踏上旅程
[01:28.130][03:48.760]暖色的海洋不断地延伸
[01:36.050][03:56.730]恍若曾几何时梦中描绘的景色
[01:40.300][04:00.990]此时感到有些伤感,是否要将时光倒转?
[01:52.490][04:13.240]No No No 现在是最好的时刻!
[01:58.620][02:42.890]
[02:20.460]与大家相遇相识让我非常开心
[02:27.090]我真的不想和大家分离
[02:31.550]我们不需要眼泪 就这么走下去吧
[02:36.980]挥挥手,再挥挥手
[02:45.370]正因为我们如此努力地追逐着光芒
[02:53.190]所以无需再说什么分别
[02:56.320]再度相会的时候,你是否还能喊出我的名字?
[03:04.320]在美好的未来中 我们紧紧相连的梦想
[03:08.560]你和我的Live and Life
[03:15.430][04:30.500][04:48.410]
[04:18.670]因为此时此刻就是最好的!
[04:37.410]Ah!我们一起追逐着那道光芒
`
abnormal = `[ar:Artist]
[ti:Title]
[00:j7.540]alskdfjlasdkjflsakdjf
Expand Down
30 changes: 30 additions & 0 deletions test/test.min.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,35 @@
[03:15.430][04:30.500][04:48.410]
[04:18.670]だってだって、いまが最高!
[04:37.410]Ah! 光を追いかけてきたんだよ…</script>
<script id='sample_complex_chinese' type='text/plain'>[00:27.540][04:31.520]Ah!由微小的预感拉开序幕
[00:32.970]Ah!希望在星空中穿梭
[00:38.450]像花朵绽放般的笑容
[00:43.920]一如既往的友情的笑容
[00:49.160]
[00:49.510]无法忘记 一直不会忘记
[00:54.940]我们的心这样连在一起
[01:00.410]见证这个世界上的快乐并为之歌唱
[01:09.940]直到最后(我们合而为一)
[01:16.660]
[01:17.040][03:37.800]小鸟的翅膀终于变得丰满
[01:25.010][03:45.640]展翅高飞踏上旅程
[01:28.130][03:48.760]暖色的海洋不断地延伸
[01:36.050][03:56.730]恍若曾几何时梦中描绘的景色
[01:40.300][04:00.990]此时感到有些伤感,是否要将时光倒转?
[01:52.490][04:13.240]No No No 现在是最好的时刻!
[01:58.620][02:42.890]
[02:20.460]与大家相遇相识让我非常开心
[02:27.090]我真的不想和大家分离
[02:31.550]我们不需要眼泪 就这么走下去吧
[02:36.980]挥挥手,再挥挥手
[02:45.370]正因为我们如此努力地追逐着光芒
[02:53.190]所以无需再说什么分别
[02:56.320]再度相会的时候,你是否还能喊出我的名字?
[03:04.320]在美好的未来中 我们紧紧相连的梦想
[03:08.560]你和我的Live and Life
[03:15.430][04:30.500][04:48.410]
[04:18.670]因为此时此刻就是最好的!
[04:37.410]Ah!我们一起追逐着那道光芒</script>
<script id='abnormal' type='text/plain'>[ar:Artist]
[ti:Title]
[00:j7.540]alskdfjlasdkjflsakdjf
Expand Down Expand Up @@ -127,6 +156,7 @@
<script>
sample = document.getElementById('sample').innerHTML;
sample_complex = document.getElementById('sample_complex').innerHTML;
sample_complex_chinese = document.getElementById('sample_complex_chinese').innerHTML;
abnormal = document.getElementById('abnormal').innerHTML;
id_tags_only = document.getElementById('id_tags_only').innerHTML;
id_tags_lyrics = document.getElementById('id_tags_lyrics').innerHTML;
Expand Down
24 changes: 24 additions & 0 deletions test/testcases.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,27 @@ QUnit.test("Test Time Offset", function(assert) {
assert.deepEqual(lrc.getLyric(lrc.select(1)), {timestamp:2,text:'Three'});
assert.deepEqual(lrc.getIDTags(), {offset:1000});
});
QUnit.test("Test Multiple Instances of Lyrics()", function(assert){
var lrc_1 = new Lyrics('[00:04.050] firstLine');
var lrc_2 = new Lyrics('[00:04.050] secondLine');
assert.deepEqual(lrc_1.getLyrics(), [{timestamp:4.05,text:'firstLine'}]);
assert.deepEqual(lrc_2.getLyrics(), [{timestamp:4.05,text:'secondLine'}]);
assert.strictEqual(lrc_1.getLyric(lrc_1.select(3)), undefined);
assert.deepEqual(lrc_1.getLyric(lrc_1.select(4.1)), {timestamp:4.05,text:'firstLine'});
assert.strictEqual(lrc_2.getLyric(lrc_2.select(3)), undefined);
assert.deepEqual(lrc_2.getLyric(lrc_2.select(4.1)), {timestamp:4.05,text:'secondLine'});
});
QUnit.test("Test Multiple Instances of Lyrics()", function(assert){
var lrc_1 = new Lyrics(sample_complex);
var lrc_2 = new Lyrics(sample_complex_chinese);

assert.deepEqual(lrc_1.getLyric(0), {timestamp:27.540,text:'Ah! ほのかな予感から始まり'});
assert.deepEqual(lrc_1.getLyric(4), {timestamp:49.160,text:''});
assert.deepEqual(lrc_2.getLyric(0), {timestamp:27.540,text:'Ah!由微小的预感拉开序幕'});
assert.deepEqual(lrc_2.getLyric(4), {timestamp:49.160,text:''});

assert.deepEqual(lrc_1.getLyric(4), {timestamp:49.160,text:''});
assert.deepEqual(lrc_2.getLyric(4), {timestamp:49.160,text:''});
assert.deepEqual(lrc_1.getLyric(0), {timestamp:27.540,text:'Ah! ほのかな予感から始まり'});
assert.deepEqual(lrc_2.getLyric(0), {timestamp:27.540,text:'Ah!由微小的预感拉开序幕'});
});

0 comments on commit cf000cb

Please sign in to comment.