emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/subed 1ef2dbb 245/389: Add more tests for inserting subtit


From: ELPA Syncer
Subject: [nongnu] elpa/subed 1ef2dbb 245/389: Add more tests for inserting subtitles adjacent with restricted space
Date: Fri, 3 Dec 2021 11:00:34 -0500 (EST)

branch: elpa/subed
commit 1ef2dbb299dadbd62602a1286f24bd81a4912f5a
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>

    Add more tests for inserting subtitles adjacent with restricted space
---
 tests/test-subed.el | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 145 insertions(+), 1 deletion(-)

diff --git a/tests/test-subed.el b/tests/test-subed.el
index 9c25e02..b98209f 100644
--- a/tests/test-subed.el
+++ b/tests/test-subed.el
@@ -1710,7 +1710,151 @@
           )
         )
       )
-
+    (describe "when there is not enough time for spacing"
+      (describe "between subtitles"
+        (describe "when prepending"
+          (it "a single subtitle."
+            (cl-loop for arg in (list '- -1 (list 4)) do
+                     (with-temp-buffer
+                       (insert (concat "1\n"
+                                       "00:00:59,000 --> 00:01:00,000\n"
+                                       "Foo.\n\n"
+                                       "2\n"
+                                       "00:01:00,005 --> 00:01:05,000\n"
+                                       "Bar.\n"))
+                       (subed-srt--jump-to-subtitle-text 2)
+                       (expect (subed-insert-subtitle-adjacent arg) :to-equal 
71)
+                       (expect (buffer-string) :to-equal (concat "1\n"
+                                                                 "00:00:59,000 
--> 00:01:00,000\n"
+                                                                 "Foo.\n\n"
+                                                                 "0\n"
+                                                                 "00:01:00,005 
--> 00:01:00,005\n"
+                                                                 "\n\n"
+                                                                 "2\n"
+                                                                 "00:01:00,005 
--> 00:01:05,000\n"
+                                                                 "Bar.\n"))
+                       (expect (point) :to-equal 71)
+                       (expect 'subed-regenerate-ids-soon 
:to-have-been-called-times 1)
+                       (spy-calls-reset 'subed-regenerate-ids-soon))))
+          (it "multiple subtitles."
+            (cl-loop for arg in (list -2 (list 16)) do
+                     (with-temp-buffer
+                       (insert (concat "1\n"
+                                       "00:00:59,000 --> 00:01:00,000\n"
+                                       "Foo.\n\n"
+                                       "2\n"
+                                       "00:01:00,025 --> 00:01:05,000\n"
+                                       "Bar.\n"))
+                       (subed-srt--jump-to-subtitle-text 2)
+                       (expect (subed-insert-subtitle-adjacent arg) :to-equal 
71)
+                       (expect (buffer-string) :to-equal (concat "1\n"
+                                                                 "00:00:59,000 
--> 00:01:00,000\n"
+                                                                 "Foo.\n\n"
+                                                                 "0\n"
+                                                                 "00:01:00,025 
--> 00:01:00,025\n"
+                                                                 "\n\n"
+                                                                 "0\n"
+                                                                 "00:01:00,025 
--> 00:01:00,025\n"
+                                                                 "\n\n"
+                                                                 "2\n"
+                                                                 "00:01:00,025 
--> 00:01:05,000\n"
+                                                                 "Bar.\n"))
+                       (expect (point) :to-equal 71)
+                       (expect 'subed-regenerate-ids-soon 
:to-have-been-called-times 1)
+                       (spy-calls-reset 'subed-regenerate-ids-soon))))
+          )
+        (describe "when appending"
+          (it "a single subtitle."
+            (cl-loop for arg in (list nil 1) do
+                     (with-temp-buffer
+                       (insert (concat "1\n"
+                                       "00:00:59,000 --> 00:01:00,000\n"
+                                       "Foo.\n\n"
+                                       "2\n"
+                                       "00:01:00,099 --> 00:01:05,000\n"
+                                       "Bar.\n"))
+                       (subed-srt--jump-to-subtitle-text 1)
+                       (expect (subed-insert-subtitle-adjacent arg) :to-equal 
71)
+                       (expect (buffer-string) :to-equal (concat "1\n"
+                                                                 "00:00:59,000 
--> 00:01:00,000\n"
+                                                                 "Foo.\n\n"
+                                                                 "0\n"
+                                                                 "00:01:00,000 
--> 00:01:00,000\n"
+                                                                 "\n\n"
+                                                                 "2\n"
+                                                                 "00:01:00,099 
--> 00:01:05,000\n"
+                                                                 "Bar.\n"))
+                       (expect (point) :to-equal 71)
+                       (expect 'subed-regenerate-ids-soon 
:to-have-been-called-times 1)
+                       (spy-calls-reset 'subed-regenerate-ids-soon))))
+          (it "multiple subtitles."
+            (cl-loop for arg in (list 2) do
+                     (with-temp-buffer
+                       (insert (concat "1\n"
+                                       "00:00:59,000 --> 00:01:00,000\n"
+                                       "Foo.\n\n"
+                                       "2\n"
+                                       "00:01:00,075 --> 00:01:05,000\n"
+                                       "Bar.\n"))
+                       (subed-srt--jump-to-subtitle-text 1)
+                       (expect (subed-insert-subtitle-adjacent arg) :to-equal 
71)
+                       (expect (buffer-string) :to-equal (concat "1\n"
+                                                                 "00:00:59,000 
--> 00:01:00,000\n"
+                                                                 "Foo.\n\n"
+                                                                 "0\n"
+                                                                 "00:01:00,000 
--> 00:01:00,000\n"
+                                                                 "\n\n"
+                                                                 "0\n"
+                                                                 "00:01:00,000 
--> 00:01:00,000\n"
+                                                                 "\n\n"
+                                                                 "2\n"
+                                                                 "00:01:00,075 
--> 00:01:05,000\n"
+                                                                 "Bar.\n"))
+                       (expect (point) :to-equal 71)
+                       (expect 'subed-regenerate-ids-soon 
:to-have-been-called-times 1)
+                       (spy-calls-reset 'subed-regenerate-ids-soon))))
+          )
+        )
+      (describe "before the first subtitle"
+        (it "a single subtitle."
+          (cl-loop for arg in (list '- -1 (list 4)) do
+                   (with-temp-buffer
+                     (insert (concat "1\n"
+                                     "00:00:00,040 --> 00:00:05,000\n"
+                                     "Foo.\n"))
+                     (subed-srt--jump-to-subtitle-text 1)
+                     (expect (subed-insert-subtitle-adjacent arg) :to-equal 33)
+                     (expect (buffer-string) :to-equal (concat "0\n"
+                                                               "00:00:00,040 
--> 00:00:00,040\n"
+                                                               "\n\n"
+                                                               "1\n"
+                                                               "00:00:00,040 
--> 00:00:05,000\n"
+                                                               "Foo.\n"))
+                     (expect (point) :to-equal 33)
+                     (expect 'subed-regenerate-ids-soon 
:to-have-been-called-times 1)
+                     (spy-calls-reset 'subed-regenerate-ids-soon))))
+        (it "multiple subtitles."
+          (cl-loop for arg in (list -2 (list 16)) do
+                   (with-temp-buffer
+                     (insert (concat "1\n"
+                                     "00:00:00,024 --> 00:00:05,000\n"
+                                     "Foo.\n"))
+                     (subed-srt--jump-to-subtitle-text 1)
+                     (expect (subed-insert-subtitle-adjacent arg) :to-equal 33)
+                     (expect (buffer-string) :to-equal (concat "0\n"
+                                                               "00:00:00,024 
--> 00:00:00,024\n"
+                                                               "\n\n"
+                                                               "0\n"
+                                                               "00:00:00,024 
--> 00:00:00,024\n"
+                                                               "\n\n"
+                                                               "1\n"
+                                                               "00:00:00,024 
--> 00:00:05,000\n"
+                                                               "Foo.\n"))
+                     (expect (point) :to-equal 33)
+                     (expect 'subed-regenerate-ids-soon 
:to-have-been-called-times 1)
+                     (spy-calls-reset 'subed-regenerate-ids-soon))))
+        )
+      )
     )
   )
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]