aboutsummaryrefslogtreecommitdiff
path: root/test/test-printing.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-printing.el')
-rw-r--r--test/test-printing.el123
1 files changed, 121 insertions, 2 deletions
diff --git a/test/test-printing.el b/test/test-printing.el
index 29c209d..677dca3 100644
--- a/test/test-printing.el
+++ b/test/test-printing.el
@@ -76,10 +76,129 @@ after being run through `sx-question--tag-format'."
"Test `sx--user-@name' character substitution"
(should
(string=
- (sx--user-@name '((display_name . "ĥÞßđłřğĝýÿñńśşšŝżźžçćčĉùúûüŭůòóôõöøőðìíîïıèéêëęàåáâäãåąĵ★")))
+ (sx-user--@name "ĥÞßđłřğĝýÿñńśşšŝżźžçćčĉùúûüŭůòóôõöøőðìíîïıèéêëęàåáâäãåąĵ★")
"@hTHssdlrggyynnsssszzzccccuuuuuuooooooooiiiiieeeeeaaaaaaaaj"))
(should
(string=
- (sx--user-@name '((display_name . "ĤÞßĐŁŘĞĜÝŸÑŃŚŞŠŜŻŹŽÇĆČĈÙÚÛÜŬŮÒÓÔÕÖØŐÐÌÍÎÏıÈÉÊËĘÀÅÁÂÄÃÅĄĴ")))
+ (sx-user--@name "ĤÞßĐŁŘĞĜÝŸÑŃŚŞŠŜŻŹŽÇĆČĈÙÚÛÜŬŮÒÓÔÕÖØŐÐÌÍÎÏıÈÉÊËĘÀÅÁÂÄÃÅĄĴ")
+ "@HTHssDLRGGYYNNSSSSZZZCCCCUUUUUUOOOOOOOOIIIIiEEEEEAAAAAAAAJ"))
+ (should-error
+ (sx-user--@name 2)))
+
+(ert-deftest sx-user--format ()
+ "Test various `sx-user--format' features."
+ (let ((user
+ '((display_name . "ĥÞßđłřğĝýÿñńśşšŝżźžçćčĉùúûüŭůòóôõöøőðìíîïıèéêëęàåáâäãåąĵ★")
+ (accept_rate . 90)
+ (reputation . 10)
+ (link . "link"))))
+ (should
+ (equal (sx-user--format "%l" user) "link"))
+ (should
+ (equal
+ (sx-user--format "%@" user)
+ "@hTHssdlrggyynnsssszzzccccuuuuuuooooooooiiiiieeeeeaaaaaaaaj"))
+ (should
+ (equal
+ (sx-user--format "%@%%d%%%-30d %9r%l" user)
+ "@hTHssdlrggyynnsssszzzccccuuuuuuooooooooiiiiieeeeeaaaaaaaaj%d%ĥÞßđłřğĝýÿñńśşšŝżźžçćčĉùúûüŭůòóôõöøőðìíîïıèéêëęàåáâäãåąĵ★ 10link")))
+ (should
+ (string=
+ (sx-user--format "%@" '((display_name . "ĤÞßĐŁŘĞĜÝŸÑŃŚŞŠŜŻŹŽÇĆČĈÙÚÛÜŬŮÒÓÔÕÖØŐÐÌÍÎÏıÈÉÊËĘÀÅÁÂÄÃÅĄĴ")))
"@HTHssDLRGGYYNNSSSSZZZCCCCUUUUUUOOOOOOOOIIIIiEEEEEAAAAAAAAJ")))
+(ert-deftest sx-object-modification ()
+ "Test adding things to objects"
+ (let ((object (list (cons 'owner "me"))))
+ (should
+ (equal (sx--ensure-owner-in-object 1 object)
+ '((owner . "me"))))
+ (should
+ (equal object '((owner . "me")))))
+ (let ((object (list (cons 'not-owner "me"))))
+ (should
+ (equal (sx--ensure-owner-in-object 1 object)
+ '((owner . 1) (not-owner . "me"))))
+ (should
+ (equal object '((owner . 1) (not-owner . "me")))))
+ (let ((object (list (cons 'comments [something]))))
+ (should
+ (equal (sx--add-comment-to-object "comment" object)
+ '((comments . [something "comment"]))))
+ (should
+ (equal object '((comments . [something "comment"])))))
+ (let ((object (list (cons 'not-comments [something]))))
+ (should
+ (equal (sx--add-comment-to-object "comment" object)
+ '((comments . ["comment"]) (not-comments . [something]))))
+ (should
+ (equal object '((comments . ["comment"]) (not-comments . [something])))))
+ (let ((object (list (cons 'not-answers [something]))))
+ (should
+ (equal (sx--add-answer-to-question-object "answer" object)
+ '((answers . ["answer"]) (not-answers . [something]))))
+ (should
+ (equal object '((answers . ["answer"]) (not-answers . [something])))))
+ (let ((object (list (cons 'answers [something]))))
+ (should
+ (equal (sx--add-answer-to-question-object "answer" object)
+ '((answers . [something "answer"]))))
+ (should
+ (equal object '((answers . [something "answer"]))))))
+
+(ert-deftest sx-question-mode--fill-and-fontify ()
+ "Check complicated questions are filled correctly."
+ (should
+ (equal
+ (sx-question-mode--fill-and-fontify
+ "Creating an account on a new site requires you to log into that site using *the same credentials you used on existing sites.* For instance, if you used the Stack Exchange login method, you'd...
+
+1. Click the \"Log in using Stack Exchange\" button:
+
+ ![][1]
+
+2. Enter your username and password (yes, even if you *just did this* to log into, say, Stack Overflow) and press the \"Log In\" button:
+
+ ![][2]
+
+3. Confirm the creation of the new account:
+
+ ![][3]
+
+ some code block
+ some code block
+ some code block
+ some code block
+ some code block
+ some code block
+
+ [1]: http://i.stack.imgur.com/ktFTs.png
+ [2]: http://i.stack.imgur.com/5l2AY.png
+ [3]: http://i.stack.imgur.com/22myl.png")
+ "Creating an account on a new site requires you to log into that site
+using *the same credentials you used on existing sites.* For instance,
+if you used the Stack Exchange login method, you'd...
+
+1. Click the \"Log in using Stack Exchange\" button:
+
+ ![][1]
+
+2. Enter your username and password (yes, even if you *just did this*
+ to log into, say, Stack Overflow) and press the \"Log In\" button:
+
+ ![][2]
+
+3. Confirm the creation of the new account:
+
+ ![][3]
+
+ some code block
+ some code block
+ some code block
+ some code block
+ some code block
+ some code block
+
+ [1]: http://i.stack.imgur.com/ktFTs.png
+ [2]: http://i.stack.imgur.com/5l2AY.png
+ [3]: http://i.stack.imgur.com/22myl.png")))