chorus/tests/user.rs

46 lines
1.4 KiB
Rust
Raw Normal View History

2024-01-30 17:19:34 +01:00
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
2024-01-23 23:06:24 +01:00
use chorus::types::{PublicUser, Snowflake, User};
2024-08-18 14:50:13 +02:00
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
#[cfg(target_arch = "wasm32")]
wasm_bindgen_test_configure!(run_in_browser);
mod common;
2024-01-23 23:06:24 +01:00
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), test)]
fn to_public_user() {
let mut user = User::default();
let mut public_user = PublicUser {
username: Some("".to_string()),
discriminator: Some("".to_string()),
..Default::default()
};
let id: Snowflake = 1_u64.into();
user.id = id;
public_user.id = id;
let from_user = user.into_public_user();
assert_eq!(public_user, from_user);
}
2024-08-18 14:50:13 +02:00
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
async fn test_get_user_profile() {
let mut bundle = common::setup().await;
let user_id = bundle.user.object.read().unwrap().id;
let user_profile = bundle
.user
.get_user_profile(user_id, chorus::types::GetUserProfileSchema::default())
.await;
assert!(user_profile.is_ok());
common::teardown(bundle).await;
}