lotsatest
This commit is contained in:
parent
0bc40b492f
commit
d79e50e48f
1 changed files with 77 additions and 0 deletions
|
@ -187,3 +187,80 @@ pub fn Post(page: String, id: String) -> Element {
|
||||||
PostElement { post }
|
PostElement { post }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{
|
||||||
|
domain::entities,
|
||||||
|
outbound::services::site::{MockSiteService, SiteServiceProvider},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gets_correct_site_info() {
|
||||||
|
let mut app = VirtualDom::new(|| {
|
||||||
|
rsx! {
|
||||||
|
App {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut mock_service = MockSiteService::new();
|
||||||
|
mock_service.expect_get_site().times(1).returning(move |_| {
|
||||||
|
Box::pin(async {
|
||||||
|
Ok(entities::site::SiteInfo {
|
||||||
|
title: "My test website".to_string(),
|
||||||
|
domain: "test.com".to_string(),
|
||||||
|
pages: vec![],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
server_context().insert(SiteServiceProvider::with(mock_service));
|
||||||
|
|
||||||
|
app.rebuild_in_place();
|
||||||
|
let elem_str = dioxus::ssr::render(&app);
|
||||||
|
assert!(elem_str.contains("My test website"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn single_gets_page_info() {
|
||||||
|
let mut app = VirtualDom::new(|| {
|
||||||
|
rsx! {
|
||||||
|
Single { page: "test".to_string() }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
testing::add_test_site_context(&mut app);
|
||||||
|
|
||||||
|
let mut mock_service = MockSiteService::new();
|
||||||
|
mock_service
|
||||||
|
.expect_get_page()
|
||||||
|
.times(1)
|
||||||
|
.returning(move |_, _| {
|
||||||
|
Box::pin(async {
|
||||||
|
Ok(entities::site::Page {
|
||||||
|
info: entities::site::PageInfo {
|
||||||
|
title: "Test page name".to_string(),
|
||||||
|
name: "test".to_string(),
|
||||||
|
order: 0,
|
||||||
|
},
|
||||||
|
content: PageContent::Single {
|
||||||
|
content: entities::site::Post {
|
||||||
|
blocks: vec![entities::site::Block::Text {
|
||||||
|
text: "test content".to_string(),
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
server_context().insert(SiteServiceProvider::with(mock_service));
|
||||||
|
|
||||||
|
app.rebuild_in_place();
|
||||||
|
let elem_str = dioxus::ssr::render(&app);
|
||||||
|
assert!(elem_str.contains("Test page name"));
|
||||||
|
assert!(elem_str.contains("test content"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue