summaryrefslogtreecommitdiffstats
path: root/spec/helpers/vtt/builder_spec.cr
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/vtt/builder_spec.cr')
-rw-r--r--spec/helpers/vtt/builder_spec.cr64
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/helpers/vtt/builder_spec.cr b/spec/helpers/vtt/builder_spec.cr
new file mode 100644
index 00000000..7b543ddc
--- /dev/null
+++ b/spec/helpers/vtt/builder_spec.cr
@@ -0,0 +1,64 @@
+require "../../spec_helper.cr"
+
+MockLines = [
+ {
+ "start_time": Time::Span.new(seconds: 1),
+ "end_time": Time::Span.new(seconds: 2),
+ "text": "Line 1",
+ },
+
+ {
+ "start_time": Time::Span.new(seconds: 2),
+ "end_time": Time::Span.new(seconds: 3),
+ "text": "Line 2",
+ },
+]
+
+Spectator.describe "WebVTT::Builder" do
+ it "correctly builds a vtt file" do
+ result = WebVTT.build do |vtt|
+ MockLines.each do |line|
+ vtt.cue(line["start_time"], line["end_time"], line["text"])
+ end
+ end
+
+ expect(result).to eq([
+ "WEBVTT",
+ "",
+ "00:00:01.000 --> 00:00:02.000",
+ "Line 1",
+ "",
+ "00:00:02.000 --> 00:00:03.000",
+ "Line 2",
+ "",
+ "",
+ ].join('\n'))
+ end
+
+ it "correctly builds a vtt file with setting fields" do
+ setting_fields = {
+ "Kind" => "captions",
+ "Language" => "en",
+ }
+
+ result = WebVTT.build(setting_fields) do |vtt|
+ MockLines.each do |line|
+ vtt.cue(line["start_time"], line["end_time"], line["text"])
+ end
+ end
+
+ expect(result).to eq([
+ "WEBVTT",
+ "Kind: captions",
+ "Language: en",
+ "",
+ "00:00:01.000 --> 00:00:02.000",
+ "Line 1",
+ "",
+ "00:00:02.000 --> 00:00:03.000",
+ "Line 2",
+ "",
+ "",
+ ].join('\n'))
+ end
+end
ivacy-redirect/commit/assets/images/logo.png?id=2335630b488783f25feda69bf2265f9f70622420&follow=1'>Losslessly compress PNG imagesFrank3K 2020-12-17add nitter.unixfox.eu as a nitter instance to the listEmilien Devos 2020-11-29Update background.jsAustin Huang 2020-11-22Updated background.jsaapl-yumi 2020-11-17Add "yewtu.be" back to the random instance listÉmilien Devos 2020-11-11Update background.jsYumi Izumi 2020-11-09Update Russian translationTotalCaesar659 2020-11-09Update README.mdYumi Izumi 2020-11-09Update options.jsYumi Izumi 2020-11-09Update options.htmlYumi Izumi 2020-11-08Update popup.jsYumi Izumi 2020-11-08Update popup.htmlYumi Izumi 2020-11-08Update background.jsYumi Izumi 2020-11-08Closes #111 - Adds ability to customise random instance poolsv1.1.43SimonBrazell 2020-11-08Fixes #119 - Change zh-CN to zh_CN.SimonBrazell 2020-11-07Update README.mdKunio 2020-11-05Update Russian translationTotalCaesar659 2020-11-04Update store listing templatesSimonBrazell 2020-11-04Update Bibliogram linksbopol 2020-11-04Remove duplicate entry in instagramReservedPaths arraySimonBrazell 2020-11-04Remove "https://yewtu.be" from random instance listSimonBrazell 2020-11-04Ignore embedded videos for FreeTube redirectsSimonBrazell 2020-11-04Fixes #99 - Bibliogram, handle /igtv/, /tv/ and /reel/v1.1.42SimonBrazell 2020-11-04Fixes #104 - /remove-twitter-sw.js stopping Twitter redirectsSimonBrazell 2020-11-04Closes #113 - Added support for FreeTubeSimonBrazell 2020-11-04Clean up invidious random instance listSimonBrazell 2020-10-23Rename _locales/store.md to _locales/pl/store.mdAustin Huang