branch: elpa/subed
commit 63bd6a83a4fdba919d1d28ecb6010737a39ed6cc
Author: Sacha Chua <[email protected]>
Commit: Sacha Chua <[email protected]>
Add tests
* tests/test-subed-common.el ("COMMON"): Add test for
subed-append-subtitles.
* tests/test-subed-vtt.el ("VTT"): Test subed-for-each-subtitle to
make sure it doesn't get confused by the header.
---
tests/test-subed-common.el | 9 +++++++++
tests/test-subed-vtt.el | 19 ++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/tests/test-subed-common.el b/tests/test-subed-common.el
index 926c210eab..878baa04f8 100644
--- a/tests/test-subed-common.el
+++ b/tests/test-subed-common.el
@@ -3433,6 +3433,15 @@ This is another.
:to-equal
'((1 61000
65123 "Foo." nil)
(2
122234 130345 "Bar." nil))))))
+ (describe "Appending a list of subtitles"
+ (it "adds them."
+ (with-temp-srt-buffer
+ (let ((list '((1 61000 65123 "Foo." nil)
+ (2
122234 130345 "Bar." nil)
+ (3
183450 195500 "Baz." nil))))
+ (subed-append-subtitle-list list)
+ (expect (subed-subtitle-list)
+ :to-equal list)))))
(describe "Getting the text of a list"
(it "returns a blank string when given nothing."
(expect (subed-subtitle-list-text nil) :to-equal ""))
diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el
index 05c1d227c5..3ff4191027 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -1385,4 +1385,21 @@ World
00:01:21.058 --> 00:01:23.868
Again")
(with-current-buffer (subed-convert "TXT" t)
- (expect (buffer-string) :to-equal "Hello\n\nNOTE
Comment\n\nWorld\nAgain\n"))))))
+ (expect (buffer-string) :to-equal "Hello\n\nNOTE
Comment\n\nWorld\nAgain\n")))))
+ (describe "iterating over subtitles"
+ (describe "forwards"
+ (it "does not get confused by the header."
+ (with-temp-vtt-buffer
+ (insert mock-vtt-data)
+ (let (result)
+ (subed-for-each-subtitle (point-min) (point-max) nil
+ (add-to-list 'result (point)))
+ (expect (length result) :to-equal 3)))))
+ (describe "backwards"
+ (it "does not get confused by the header."
+ (with-temp-vtt-buffer
+ (insert mock-vtt-data)
+ (let (result)
+ (subed-for-each-subtitle (point-min) (point-max) t
+ (add-to-list 'result (point)))
+ (expect (length result) :to-equal 3)))))))