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

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

[nongnu] elpa/org-mime 4bd5d55ba9 071/118: fixed logic


From: ELPA Syncer
Subject: [nongnu] elpa/org-mime 4bd5d55ba9 071/118: fixed logic
Date: Wed, 5 Jan 2022 07:58:48 -0500 (EST)

branch: elpa/org-mime
commit 4bd5d55ba9bca84ffd938b477c72d701cf3736df
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    fixed logic
---
 org-mime.el            | 20 ++++++--------------
 test/org-mime-tests.el | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/org-mime.el b/org-mime.el
index 0fb34a3954..97c964a9be 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -482,20 +482,12 @@ If SUBTREEP is t, curret org node is subtree."
 
 (defun org-mime-build-mail-other-headers (cc bcc from)
   "Build mail header from CC, BCC, and FROM."
-  (cond
-   ((and cc bcc from)
-    (list (cons "Cc" cc)
-          (cons "Bcc" bcc)
-          (cons "From" from)
-          ))
-   (cc
-    (list (cons "Cc" cc)))
-   (bcc
-    (list (cons "Bcc" bcc)))
-   (from
-    (list (cons "From" from)))
-   (t
-    nil)))
+  (let* ((arr (list (cons "Cc" cc) (cons "Bcc" bcc)  (cons "From" from )))
+         rlt)
+    (dolist (e arr)
+      (when (cdr e)
+        (push e rlt)))
+    rlt))
 
 ;;;###autoload
 (defun org-mime-org-buffer-htmlize ()
diff --git a/test/org-mime-tests.el b/test/org-mime-tests.el
index 556b3b552a..dea0846277 100644
--- a/test/org-mime-tests.el
+++ b/test/org-mime-tests.el
@@ -86,4 +86,32 @@
       (setq str (buffer-string)))
     (should (string-match "<#multipart" str))))
 
+(ert-deftest test-org-mime-build-mail-other-headers ()
+ (let* ((cc "cc@m.c")
+        (bcc "bcc@m.c")
+        (from "from@m.c")
+        h)
+   ;; CC
+   (setq h (nth 0 (org-mime-build-mail-other-headers cc nil nil)))
+   (should (string= (car h) "Cc"))
+
+   ;; CC and BCC
+   (setq h (nth 0 (org-mime-build-mail-other-headers cc bcc nil)))
+   (should (string= (car h) "Bcc"))
+   (should (string= (cdr h) bcc))
+   (setq h (nth 1 (org-mime-build-mail-other-headers cc bcc nil)))
+   (should (string= (car h) "Cc"))
+   (should (string= (cdr h) cc))
+
+   ;; CC, BCC, and FROM
+   (setq h (nth 0 (org-mime-build-mail-other-headers cc bcc from)))
+   (should (string= (car h) "From"))
+   (should (string= (cdr h) from))
+   (setq h (nth 1 (org-mime-build-mail-other-headers cc bcc from)))
+   (should (string= (car h) "Bcc"))
+   (should (string= (cdr h) bcc))
+   (setq h (nth 2 (org-mime-build-mail-other-headers cc bcc from)))
+   (should (string= (car h) "Cc"))
+   (should (string= (cdr h) cc))))
+
 (ert-run-tests-batch-and-exit)
\ No newline at end of file



reply via email to

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