Add tests for coverage
This commit is contained in:
parent
e06edada1e
commit
dd01ef0c35
|
@ -9,7 +9,7 @@ async fn main() {
|
|||
"wss://example.com/".to_string(),
|
||||
"https://example.com/cdn".to_string(),
|
||||
);
|
||||
let instance = Instance::new(bundle, true)
|
||||
let mut instance = Instance::new(bundle, true)
|
||||
.await
|
||||
.expect("Failed to connect to the Spacebar server");
|
||||
// Assume, you already have an account created on this instance. Registering an account works
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use chorus::types::RegisterSchema;
|
||||
use std::borrow::BorrowMut;
|
||||
|
||||
use chorus::types::{LoginSchema, RegisterSchema};
|
||||
// PRETTYFYME: Move common wasm setup to common.rs
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen_test::*;
|
||||
|
@ -10,14 +12,59 @@ mod common;
|
|||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
||||
async fn test_registration() {
|
||||
let bundle = common::setup().await;
|
||||
let mut bundle = common::setup().await;
|
||||
let reg = RegisterSchema {
|
||||
username: "Hiiii".into(),
|
||||
date_of_birth: Some("2000-01-01".to_string()),
|
||||
consent: true,
|
||||
..Default::default()
|
||||
};
|
||||
bundle.instance.clone().register_account(reg).await.unwrap();
|
||||
bundle.instance.register_account(reg).await.unwrap();
|
||||
common::teardown(bundle).await;
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
||||
async fn test_login() {
|
||||
let mut bundle = common::setup().await;
|
||||
let reg = RegisterSchema {
|
||||
username: "Hiiii".into(),
|
||||
email: Some("testuser1@integrationtesting.xyz".into()),
|
||||
password: Some("Correct-Horse-Battery-Staple1".into()),
|
||||
date_of_birth: Some("2000-01-01".to_string()),
|
||||
consent: true,
|
||||
..Default::default()
|
||||
};
|
||||
bundle.instance.register_account(reg).await.unwrap();
|
||||
let login = LoginSchema {
|
||||
login: "testuser1@integrationtesting.xyz".into(),
|
||||
password: "Correct-Horse-Battery-Staple1".into(),
|
||||
..Default::default()
|
||||
};
|
||||
bundle.instance.login_account(login).await.unwrap();
|
||||
common::teardown(bundle).await;
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
||||
async fn test_wrong_login() {
|
||||
let mut bundle = common::setup().await;
|
||||
let reg = RegisterSchema {
|
||||
username: "Hiiii".into(),
|
||||
email: Some("testuser2@integrationtesting.xyz".into()),
|
||||
password: Some("Correct-Horse-Battery-Staple1".into()),
|
||||
date_of_birth: Some("2000-01-01".to_string()),
|
||||
consent: true,
|
||||
..Default::default()
|
||||
};
|
||||
bundle.instance.register_account(reg).await.unwrap();
|
||||
let login = LoginSchema {
|
||||
login: "testuser2@integrationtesting.xyz".into(),
|
||||
password: "Correct-Horse-Battery-Staple2".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let res = bundle.instance.login_account(login).await;
|
||||
assert!(res.is_err());
|
||||
common::teardown(bundle).await;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue