Skip to content

Commit 99533da

Browse files
committed
add tests
1 parent 950119e commit 99533da

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

tests/models/serialize_test_case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SerializeTestCase(unittest.TestCase):
3737
LOCATION = 'location'
3838
FLEX = 'flex'
3939
SPACER = 'spacer'
40+
SPAN = 'span'
4041
BUBBLE = 'bubble'
4142
CAROUSEL = 'carousel'
4243
BOX = 'box'

tests/models/test_flex_message.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
FillerComponent,
3131
IconComponent,
3232
SpacerComponent,
33+
SpanComponent,
3334
URIAction,
3435
)
3536
from tests.models.serialize_test_case import SerializeTestCase
@@ -44,7 +45,7 @@ def test_flex_message(self):
4445
body=BoxComponent(
4546
layout='vertical',
4647
contents=[
47-
TextComponent(text='hello', wrap=True, maxLines=1),
48+
TextComponent(text='hello', wrap=True, max_lines=1),
4849
TextComponent(text='world')
4950
]
5051
)
@@ -140,7 +141,11 @@ def test_box_component(self):
140141
ImageComponent(url='https://example.com/flex/images/image.jpg'),
141142
SeparatorComponent(),
142143
TextComponent(text='Text in the box'),
143-
]
144+
],
145+
'background_color': '#00000000',
146+
'border_width': 'light',
147+
'corner_radius': 'xs',
148+
'flex': 2
144149
}
145150

146151
self.assertEqual(
@@ -162,7 +167,9 @@ def test_button_component(self):
162167
)
163168

164169
def test_filler_component(self):
165-
arg = {}
170+
arg = {
171+
'flex': 2
172+
}
166173
self.assertEqual(
167174
self.serialize_as_dict(arg, type=self.FILLER),
168175
FillerComponent(**arg).as_json_dict()
@@ -192,7 +199,8 @@ def test_image_component(self):
192199

193200
def test_separator_component(self):
194201
arg = {
195-
'color': '#000000'
202+
'color': '#000000',
203+
'margin': 'xxl'
196204
}
197205
self.assertEqual(
198206
self.serialize_as_dict(arg, type=self.SEPARATOR),
@@ -208,12 +216,31 @@ def test_spacer_component(self):
208216
SpacerComponent(**arg).as_json_dict()
209217
)
210218

219+
def test_span_component(self):
220+
arg = {
221+
'type': 'span',
222+
'text': '蛙',
223+
'size': 'xxl',
224+
'weight': 'bold',
225+
'style': 'italic',
226+
'color': '#4f8f00',
227+
'decoration': 'underline'
228+
}
229+
self.assertEqual(
230+
self.serialize_as_dict(arg, type=self.SPAN),
231+
SpanComponent(**arg).as_json_dict()
232+
)
233+
211234
def test_text_component(self):
212235
arg = {
213236
'text': 'Hello, World!',
214237
'size': 'xl',
215238
'weight': 'bold',
216-
'color': '#0000ff'
239+
'color': '#0000ff',
240+
'position': 'relative',
241+
'offset_top': '10px',
242+
'decoration': 'underline',
243+
'max_lines': 2
217244
}
218245
self.assertEqual(
219246
self.serialize_as_dict(arg, type=self.TEXT),

0 commit comments

Comments
 (0)