New feature: toggle visibility of mime buttons.
[more-wl.git] / tests / test-wl-draft.el
blobfb485743df6712c07f9026c5d18487375a7aabb3
1 (require 'lunit)
2 (require 'wl-draft)
4 (luna-define-class test-wl-draft (lunit-test-case))
6 (luna-define-method test-wl-draft-deduce-address-list-1 ((case test-wl-draft))
7 (lunit-assert
8 (equal
9 '("foo@example.com" "bar@example.com")
10 (with-temp-buffer
11 (insert "To: foo@example.com, bar@example.com
13 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
15 (luna-define-method test-wl-draft-deduce-address-list-2 ((case test-wl-draft))
16 (lunit-assert
17 (equal
18 '("foo@example.com" "bar@example.com")
19 (with-temp-buffer
20 (insert "To: foo@example.com
21 Cc: bar@example.com
23 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
25 ;; RFC 2822 A.1.2. Different types of mailboxes
26 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-example-1 ((case test-wl-draft))
27 (lunit-assert
28 (equal
29 '("mary@x.test" "jdoe@example.org" "one@y.test" "boss@nil.test" "sysservices@example.net")
30 (with-temp-buffer
31 (insert "From: \"Joe Q. Public\" <john.q.public@example.com>
32 To: Mary Smith <mary@x.test>, jdoe@example.org, Who? <one@y.test>
33 Cc: <boss@nil.test>, \"Giant; \\\"Big\\\" Box\" <sysservices@example.net>
34 Date: Tue, 1 Jul 2003 10:52:37 +0200
35 Message-ID: <5678.21-Nov-1997@example.com>
37 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
39 ;; RFC 2822 A.1.3. Group addresses
40 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-example-2 ((case test-wl-draft))
41 (lunit-assert
42 (equal
43 '("c@a.test" "joe@where.test" "jdoe@one.test")
44 (with-temp-buffer
45 (insert "From: Pete <pete@silly.example>
46 To: A Group:Chris Jones <c@a.test>,joe@where.test,John <jdoe@one.test>;
47 Cc: Undisclosed recipients:;
48 Date: Thu, 13 Feb 1969 23:32:54 -0330
49 Message-ID: <testabcd.1234@silly.example>
51 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
53 ;; RFC 2822 A.3. Resent messages
54 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-example-3 ((case test-wl-draft))
55 (lunit-assert
56 (equal
57 '("j-brown@other.example")
58 (with-temp-buffer
59 (insert "Resent-From: Mary Smith <mary@example.net>
60 Resent-To: Jane Brown <j-brown@other.example>
61 Resent-Date: Mon, 24 Nov 1997 14:22:01 -0800
62 Resent-Message-ID: <78910@example.net>
63 From: John Doe <jdoe@machine.example>
64 To: Mary Smith <mary@example.net>
65 Subject: Saying Hello
66 Date: Fri, 21 Nov 1997 09:55:06 -0600
67 Message-ID: <1234@local.machine.example>
69 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
71 ;; obs-phrase
72 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-obs-1 ((case test-wl-draft))
73 (lunit-assert
74 (equal
75 '("foo@example.com")
76 (with-temp-buffer
77 (insert "To: foo.bar <foo@example.com>
79 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
81 ;; multiple occurrences of destination address fields
82 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-obs-2 ((case test-wl-draft))
83 (lunit-assert
84 (equal
85 '("foo@example.com" "bar@example.com")
86 (with-temp-buffer
87 (insert "To: foo@example.com
88 To: bar@example.com
90 (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))