[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 46aeb10 020/389: Add more tests for forward/backward
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 46aeb10 020/389: Add more tests for forward/backward movement |
Date: |
Fri, 3 Dec 2021 10:59:49 -0500 (EST) |
branch: elpa/subed
commit 46aeb1095b6fc86f1459939b2e880c4eaa2b7072
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
Add more tests for forward/backward movement
---
tests/test-subed-srt.el | 151 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 149 insertions(+), 2 deletions(-)
diff --git a/tests/test-subed-srt.el b/tests/test-subed-srt.el
index 6b70c36..97182e1 100644
--- a/tests/test-subed-srt.el
+++ b/tests/test-subed-srt.el
@@ -284,14 +284,14 @@ Baz.
(expect (looking-back "^Baz.$") :to-be t)))
)
(describe "to next subtitle ID"
- (it "returns subtitle ID's point when it moved."
+ (it "returns point when there is a next subtitle."
(with-temp-buffer
(insert mock-srt-data)
(subed-srt-move-to-subtitle-id 2)
(expect (thing-at-point 'word) :to-equal "2")
(expect (subed-srt-forward-subtitle-id) :to-be 77)
(expect (thing-at-point 'word) :to-equal "3")))
- (it "returns nil and doesn't move when point is on the
last subtitle and there are trailing lines."
+ (it "returns nil and doesn't move when there is no next
subtitle."
(with-temp-buffer
(insert (concat mock-srt-data "\n\n"))
(subed-srt-move-to-subtitle-text 3)
@@ -299,6 +299,153 @@ Baz.
(expect (subed-srt-forward-subtitle-id) :to-be nil)
(expect (thing-at-point 'word) :to-equal "Baz")))
)
+ (describe "to previous subtitle ID"
+ (it "returns point when there is a previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 2)
+ (expect (thing-at-point 'word) :to-equal "2")
+ (expect (subed-srt-backward-subtitle-id) :to-be 1)
+ (expect (thing-at-point 'word) :to-equal "1")))
+ (it "returns nil and doesn't move when there is no
previous subtitle."
+ (with-temp-buffer
+ (goto-char (point-min))
+ (insert (concat mock-srt-data "\n\n"))
+ (subed-srt-move-to-subtitle-id 1)
+ (expect (thing-at-point 'word) :to-equal "1")
+ (expect (subed-srt-backward-subtitle-id) :to-be nil)
+ (expect (thing-at-point 'word) :to-equal "1")))
+ )
+ (describe "to next subtitle text"
+ (it "returns point when there is a next subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 1)
+ (expect (thing-at-point 'word) :to-equal "1")
+ (expect (subed-srt-forward-subtitle-text) :to-be 71)
+ (expect (thing-at-point 'word) :to-equal "Bar")))
+ (it "returns nil and doesn't move when there is no next
subtitle."
+ (with-temp-buffer
+ (goto-char (point-max))
+ (insert (concat mock-srt-data "\n\n"))
+ (subed-srt-move-to-subtitle-id 3)
+ (expect (thing-at-point 'word) :to-equal "3")
+ (expect (subed-srt-forward-subtitle-text) :to-be nil)
+ (expect (thing-at-point 'word) :to-equal "3")))
+ )
+ (describe "to previous subtitle text"
+ (it "returns point when there is a previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 3)
+ (expect (thing-at-point 'word) :to-equal "3")
+ (expect (subed-srt-backward-subtitle-text) :to-be 71)
+ (expect (thing-at-point 'word) :to-equal "Bar")))
+ (it "returns nil and doesn't move when there is no
previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (goto-char (point-min))
+ (expect (thing-at-point 'word) :to-equal "1")
+ (expect (subed-srt-backward-subtitle-text) :to-be
nil)
+ (expect (thing-at-point 'word) :to-equal "1")))
+ )
+ (describe "to next subtitle end"
+ (it "returns point when there is a next subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-text 2)
+ (expect (thing-at-point 'word) :to-equal "Bar")
+ (expect (subed-srt-forward-subtitle-end) :to-be 113)
+ (expect (thing-at-point 'word) :to-equal nil)))
+ (it "returns nil and doesn't move when there is no next
subtitle."
+ (with-temp-buffer
+ (insert (concat mock-srt-data "\n\n"))
+ (subed-srt-move-to-subtitle-text 3)
+ (end-of-line)
+ (expect (thing-at-point 'word) :to-equal nil)
+ (expect (subed-srt-forward-subtitle-end) :to-be nil)
+ (expect (thing-at-point 'word) :to-equal nil)))
+ )
+ (describe "to previous subtitle end"
+ (it "returns point when there is a previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 3)
+ (expect (thing-at-point 'word) :to-equal "3")
+ (expect (subed-srt-backward-subtitle-text) :to-be 71)
+ (expect (thing-at-point 'word) :to-equal "Bar")))
+ (it "returns nil and doesn't move when there is no
previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (goto-char (point-min))
+ (expect (thing-at-point 'word) :to-equal "1")
+ (expect (subed-srt-backward-subtitle-text) :to-be
nil)
+ (expect (thing-at-point 'word) :to-equal "1")))
+ )
+ (describe "to next subtitle's start time"
+ (it "returns point when there is a next subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-text 1)
+ (expect (thing-at-point 'word) :to-equal "Foo")
+ (expect (subed-srt-forward-subtitle-time-start)
:to-be 41)
+ (expect (thing-at-point 'word) :to-equal "00")))
+ (it "returns nil and doesn't move when there is no next
subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 3)
+ (expect (thing-at-point 'word) :to-equal "3")
+ (expect (subed-srt-forward-subtitle-time-start)
:to-be nil)
+ (expect (thing-at-point 'word) :to-equal "3")))
+ )
+ (describe "to previous subtitle's start time"
+ (it "returns point when there is a previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 2)
+ (expect (thing-at-point 'word) :to-equal "2")
+ (expect (subed-srt-backward-subtitle-time-start)
:to-be 3)
+ (expect (thing-at-point 'word) :to-equal "00")))
+ (it "returns nil and doesn't move when there is no
previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 1)
+ (expect (thing-at-point 'word) :to-equal "1")
+ (expect (subed-srt-backward-subtitle-time-start)
:to-be nil)
+ (expect (thing-at-point 'word) :to-equal "1")))
+ )
+ (describe "to next subtitle's stop time"
+ (it "returns point when there is a next subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-text 1)
+ (expect (thing-at-point 'word) :to-equal "Foo")
+ (expect (subed-srt-forward-subtitle-time-stop)
:to-be 58)
+ (expect (thing-at-point 'word) :to-equal "00")))
+ (it "returns nil and doesn't move when there is no next
subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 3)
+ (expect (thing-at-point 'word) :to-equal "3")
+ (expect (subed-srt-forward-subtitle-time-stop)
:to-be nil)
+ (expect (thing-at-point 'word) :to-equal "3")))
+ )
+ (describe "to previous subtitle's stop time"
+ (it "returns point when there is a previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 3)
+ (expect (thing-at-point 'word) :to-equal "3")
+ (expect (subed-srt-backward-subtitle-time-stop)
:to-be 58)
+ (expect (thing-at-point 'word) :to-equal "00")))
+ (it "returns nil and doesn't move when there is no
previous subtitle."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 1)
+ (expect (thing-at-point 'word) :to-equal "1")
+ (expect (subed-srt-backward-subtitle-time-stop)
:to-be nil)
+ (expect (thing-at-point 'word) :to-equal "1")))
+ )
)
- [nongnu] branch elpa/subed created (now d0dfa1a), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6a12f22 002/389: When debugging, don't autoscroll if debug-window is hidden, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d8bf4ed 001/389: Initial commit, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 2ff368b 004/389: Move subed-subtitle-time-adjusted-hook where it belongs, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9d54f39 005/389: Be more robust when getting start/stop time, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 433f7b4 003/389: subed-disable-sync-point-to-player-temporarily: Remove debug msgs, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 70e6cea 015/389: README: Test unicode non-breaking space, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d98325c 011/389: Add tests for getting subtitle start/stop time, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 73419ca 021/389: Make forward/backward movement tests pass, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 99a235a 019/389: Spoon trailing parens, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 46aeb10 020/389: Add more tests for forward/backward movement,
ELPA Syncer <=
- [nongnu] elpa/subed fd7c2ba 017/389: Add tests for getting relative point within subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ac4bc87 025/389: Add more tests for moving to subtitle ID, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7d4caaa 018/389: Move time adjustment tests, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f8a7c6a 029/389: Fix test that failed because of lexical scoping, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b3f2776 032/389: Adjust some test descriptions and apply cosmetics, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 4b16d97 033/389: Trying to do more resilient srt parsing, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 63f0ef5 040/389: In general, subtitle separator must be two or more newlines, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 52ee2ac 006/389: Be more robust when getting subtitle's relative point, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5131bc4 009/389: Add subed-srt-forward/backward-subtitle-end functions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c04670a 007/389: Adjust some docstrimgs, ELPA Syncer, 2021/12/03