tide-jsx v0.4.0
git clone https://git.pyrossh.dev/tide-jsx
Tide + JSX
4650209
— Peter John
2022-09-25T14:50:25+05:30
add integration test
Generated files not shown: Cargo.lock
- Cargo.toml +1 -0
- tests/lib.rs +27 -0
Cargo.toml
CHANGED
|
@@ -18,3 +18,4 @@ tide = "0.16.0"
|
|
|
18
18
|
pretty_assertions = "0.6"
|
|
19
19
|
async-std = { version = "1.9.0", features = ["attributes"] }
|
|
20
20
|
trybuild = "1.0"
|
|
21
|
+
tide-testing = "0.1.3"
|
tests/lib.rs
CHANGED
|
@@ -251,3 +251,30 @@ mod other {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
mod integration {
|
|
256
|
+
use crate::view;
|
|
257
|
+
use tide_testing::TideTestingExt;
|
|
258
|
+
|
|
259
|
+
#[async_std::test]
|
|
260
|
+
async fn test_server() -> tide::Result<()> {
|
|
261
|
+
let mut app = tide::new();
|
|
262
|
+
app.at("/").get(|_| async {
|
|
263
|
+
view! {
|
|
264
|
+
<div>
|
|
265
|
+
<p>{"Hello World"}</p>
|
|
266
|
+
</div>
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
assert_eq!(
|
|
271
|
+
app.get("/").recv_string().await?,
|
|
272
|
+
"<div><p>Hello World</p></div>"
|
|
273
|
+
);
|
|
274
|
+
assert_eq!(
|
|
275
|
+
app.post("/missing").await?.status(),
|
|
276
|
+
tide::http::StatusCode::NotFound
|
|
277
|
+
);
|
|
278
|
+
Ok(())
|
|
279
|
+
}
|
|
280
|
+
}
|