1+ /*
2+ # This Source Code Form is subject to the terms of the Mozilla Public
3+ # License, v. 2.0. If a copy of the MPL was not distributed with this
4+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5+ */
6+ "use strict" ;
7+
8+ import { TypicalReplyConfig , ButtonConfig , Config } from "../../src/web/config.mjs" ;
9+ import { assert } from "tiny-esm-test-runner" ;
10+ const { is } = assert ;
11+
12+ test_TypicalReplyConfig_constructor . parameters = {
13+ "empty" : {
14+ argument : {
15+ } ,
16+ expected : {
17+ priority : 0 ,
18+ configList : [ ]
19+ } ,
20+ } ,
21+ "full" : {
22+ argument : {
23+ "Priority" : 1 ,
24+ "ConfigList" : [
25+ {
26+ "Culture" : "ja-JP" ,
27+ "GroupLabel" : "定型返信" ,
28+ "ButtonConfigList" : [
29+ {
30+ "Id" : "button1" ,
31+ "Label" : "いいね!" ,
32+ "Subject" : "件名" ,
33+ "SubjectPrefix" : "[[いいね!]]" ,
34+ "Body" : "いいね!" ,
35+ "Recipients" : [
36+ "test@example.com"
37+ ] ,
38+ "QuoteType" : true ,
39+ "AllowedDomains" : [
40+ "*"
41+ ] ,
42+ "ForwardType" : "Attachment" ,
43+ }
44+ ]
45+ } ,
46+ ]
47+ } ,
48+ expected : {
49+ priority : 1 ,
50+ configList : [
51+ {
52+ culture : "ja-JP" ,
53+ groupLabel : "定型返信" ,
54+ buttonConfigList : [
55+ {
56+ id : "button1" ,
57+ label : "いいね!" ,
58+ subjectPrefix : "[[いいね!]]" ,
59+ subject : "件名" ,
60+ body : "いいね!" ,
61+ recipients : [
62+ "test@example.com"
63+ ] ,
64+ recipientsType : 4 ,
65+ quoteType : true ,
66+ allowedDomains : [ "*" ] ,
67+ allowedDomainsType : 1 ,
68+ forwardType : 1 ,
69+ } ,
70+ ] ,
71+ } ,
72+ ] ,
73+ }
74+ }
75+ }
76+ export function test_TypicalReplyConfig_constructor ( { argument, expected } ) {
77+ const typicalReplyConfig = new TypicalReplyConfig ( argument ) ;
78+ is (
79+ typicalReplyConfig ,
80+ expected
81+ ) ;
82+ }
83+
84+ test_ButtonConfig_constructor . parameters = {
85+ "empty" : {
86+ argument : {
87+ } ,
88+ expected : {
89+ id : "" ,
90+ label : "" ,
91+ subjectPrefix : "" ,
92+ subject : "" ,
93+ body : "" ,
94+ recipients : [ ] ,
95+ recipientsType : 1 ,
96+ quoteType : false ,
97+ allowedDomains : [ ] ,
98+ allowedDomainsType : 1 ,
99+ forwardType : 0 ,
100+ } ,
101+ } ,
102+ "full" : {
103+ argument : {
104+ "Id" : "button1" ,
105+ "Label" : "いいね!" ,
106+ "Subject" : "件名" ,
107+ "SubjectPrefix" : "[[いいね!]]" ,
108+ "Body" : "いいね!" ,
109+ "Recipients" : [
110+ "test@example.com"
111+ ] ,
112+ "QuoteType" : true ,
113+ "AllowedDomains" : [
114+ "*"
115+ ] ,
116+ "ForwardType" : "Attachment" ,
117+ } ,
118+ expected : {
119+ id : "button1" ,
120+ label : "いいね!" ,
121+ subjectPrefix : "[[いいね!]]" ,
122+ subject : "件名" ,
123+ body : "いいね!" ,
124+ recipients : [
125+ "test@example.com"
126+ ] ,
127+ recipientsType : 4 ,
128+ quoteType : true ,
129+ allowedDomains : [ "*" ] ,
130+ allowedDomainsType : 1 ,
131+ forwardType : 1 ,
132+ }
133+ } ,
134+ "parse ForwardType Inline" : {
135+ argument : {
136+ "ForwardType" : "Inline" ,
137+ } ,
138+ expected : {
139+ id : "" ,
140+ label : "" ,
141+ subjectPrefix : "" ,
142+ subject : "" ,
143+ body : "" ,
144+ recipients : [ ] ,
145+ recipientsType : 1 ,
146+ quoteType : false ,
147+ allowedDomains : [ ] ,
148+ allowedDomainsType : 1 ,
149+ forwardType : 2 ,
150+ }
151+ } ,
152+ "parse RecipientsType Blank" : {
153+ argument : {
154+ "Recipients" : [ ] ,
155+ } ,
156+ expected : {
157+ id : "" ,
158+ label : "" ,
159+ subjectPrefix : "" ,
160+ subject : "" ,
161+ body : "" ,
162+ recipients : [ ] ,
163+ recipientsType : 1 ,
164+ quoteType : false ,
165+ allowedDomains : [ ] ,
166+ allowedDomainsType : 1 ,
167+ forwardType : 0 ,
168+ }
169+ } ,
170+ "parse RecipientsType Sender" : {
171+ argument : {
172+ "Recipients" : [ "Sender" ] ,
173+ } ,
174+ expected : {
175+ id : "" ,
176+ label : "" ,
177+ subjectPrefix : "" ,
178+ subject : "" ,
179+ body : "" ,
180+ recipients : [ "Sender" ] ,
181+ recipientsType : 2 ,
182+ quoteType : false ,
183+ allowedDomains : [ ] ,
184+ allowedDomainsType : 1 ,
185+ forwardType : 0 ,
186+ }
187+ } ,
188+ "parse RecipientsType All" : {
189+ argument : {
190+ "Recipients" : [ "All" ] ,
191+ } ,
192+ expected : {
193+ id : "" ,
194+ label : "" ,
195+ subjectPrefix : "" ,
196+ subject : "" ,
197+ body : "" ,
198+ recipients : [ "All" ] ,
199+ recipientsType : 3 ,
200+ quoteType : false ,
201+ allowedDomains : [ ] ,
202+ allowedDomainsType : 1 ,
203+ forwardType : 0 ,
204+ }
205+ } ,
206+ "parse RecipientsType SpecifiedByUser" : {
207+ argument : {
208+ "Recipients" : [ "test@example.com" ] ,
209+ } ,
210+ expected : {
211+ id : "" ,
212+ label : "" ,
213+ subjectPrefix : "" ,
214+ subject : "" ,
215+ body : "" ,
216+ recipients : [ "test@example.com" ] ,
217+ recipientsType : 4 ,
218+ quoteType : false ,
219+ allowedDomains : [ ] ,
220+ allowedDomainsType : 1 ,
221+ forwardType : 0 ,
222+ }
223+ } ,
224+ "parse AllowedDomainsType All" : {
225+ argument : {
226+ "AllowedDomains" : [ "*" ] ,
227+ } ,
228+ expected : {
229+ id : "" ,
230+ label : "" ,
231+ subjectPrefix : "" ,
232+ subject : "" ,
233+ body : "" ,
234+ recipients : [ ] ,
235+ recipientsType : 1 ,
236+ quoteType : false ,
237+ allowedDomains : [ "*" ] ,
238+ allowedDomainsType : 1 ,
239+ forwardType : 0 ,
240+ }
241+ } ,
242+ "parse AllowedDomainsType SpecifiedByUser" : {
243+ argument : {
244+ "AllowedDomains" : [ "example.com" ] ,
245+ } ,
246+ expected : {
247+ id : "" ,
248+ label : "" ,
249+ subjectPrefix : "" ,
250+ subject : "" ,
251+ body : "" ,
252+ recipients : [ ] ,
253+ recipientsType : 1 ,
254+ quoteType : false ,
255+ allowedDomains : [ "example.com" ] ,
256+ allowedDomainsType : 2 ,
257+ forwardType : 0 ,
258+ }
259+ } ,
260+ }
261+ export function test_ButtonConfig_constructor ( { argument, expected } ) {
262+ const buttonConfig = new ButtonConfig ( argument ) ;
263+ is (
264+ buttonConfig ,
265+ expected
266+ ) ;
267+ }
0 commit comments