Skip to content

Commit 4d68b22

Browse files
authored
feat!: modify section block to follow new patterns (#34)
eagerly implement common traits, hide fields behind easy-to-use setters, doc comments
1 parent 46422f4 commit 4d68b22

File tree

4 files changed

+200
-217
lines changed

4 files changed

+200
-217
lines changed

src/blocks/mod.rs

+3-38
Original file line numberDiff line numberDiff line change
@@ -81,43 +81,8 @@ impl Block {
8181
}
8282

8383
impl_from_contents!(Block, Section, section::Contents);
84+
impl_from_contents!(Block, Image, image::Contents);
8485
impl_from_contents!(Block, Actions, actions::Contents);
8586
impl_from_contents!(Block, Context, context::Contents);
86-
87-
#[cfg(test)]
88-
mod tests {
89-
use test_case::test_case;
90-
91-
use super::*;
92-
93-
#[test_case(
94-
r#"{
95-
"type": "section",
96-
"text": {
97-
"type": "mrkdwn",
98-
"text": "my message"
99-
}
100-
}"#
101-
=> matches Block::Section(section::Contents::Text(_));
102-
"section_text"
103-
)]
104-
#[test_case(
105-
r#"{
106-
"type": "section",
107-
"fields": [{
108-
"type": "mrkdwn",
109-
"text": "my message"
110-
}]
111-
}"#
112-
=> matches Block::Section (section::Contents::Fields(_));
113-
"section_fields"
114-
)]
115-
pub fn block_should_deserialize(json: &str) -> Block {
116-
// arrange
117-
118-
// act
119-
serde_json::from_str::<Block>(&json).expect("Failed to serialize")
120-
121-
// assert
122-
}
123-
}
87+
impl_from_contents!(Block, Input, input::Contents);
88+
impl_from_contents!(Block, File, file::Contents);

0 commit comments

Comments
 (0)