aboutsummaryrefslogtreecommitdiff
path: root/minecraft-chat/tests
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-15 23:10:55 -0600
committermat <github@matdoes.dev>2021-12-15 23:10:55 -0600
commit9642558f8f8d983a7087f15d68be8cf07a85f0c2 (patch)
tree5f0a967f005cd5db510a13ab290c8ad6669b25aa /minecraft-chat/tests
parent72aefe871ca4983431b1a0b707b472e73ffea836 (diff)
downloadazalea-drasl-9642558f8f8d983a7087f15d68be8cf07a85f0c2.tar.xz
azalea
Diffstat (limited to 'minecraft-chat/tests')
-rw-r--r--minecraft-chat/tests/integration_test.rs75
1 files changed, 0 insertions, 75 deletions
diff --git a/minecraft-chat/tests/integration_test.rs b/minecraft-chat/tests/integration_test.rs
deleted file mode 100644
index aac12875..00000000
--- a/minecraft-chat/tests/integration_test.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-use minecraft_chat::{
- component::Component,
- style::{Ansi, ChatFormatting, TextColor},
-};
-use serde::Deserialize;
-use serde_json::Value;
-
-#[test]
-fn basic_ansi_test() {
- let j: Value = serde_json::from_str(
- r#"{
- "text": "hello",
- "color": "red",
- "bold": true
-}"#,
- )
- .unwrap();
- let component = Component::deserialize(&j).unwrap();
- assert_eq!(
- component.to_ansi(None),
- "\u{1b}[1m\u{1b}[38;2;255;85;85mhello\u{1b}[m"
- );
-}
-
-#[test]
-fn complex_ansi_test() {
- let j: Value = serde_json::from_str(
- r##"[
- {
- "text": "hello",
- "color": "red",
- "bold": true,
- "italic": true,
- "underlined": true,
- "adsfsf": "this should be ignored",
- "extra": [
- {"text": " ", "underlined": false},
- {"text": "world", "bold": false, "strikethrough": true, "color": "#abcdef"}
- ]
- },
- {
- "text": " asdf",
- "italic": false,
- "obfuscated": "true",
- "strikethrough": false
- },
- {
- "text": "!",
- "bold": true
- }
-]"##,
- )
- .unwrap();
- let component = Component::deserialize(&j).unwrap();
- assert_eq!(
- component.to_ansi(None),
- format!(
- "{bold}{italic}{underlined}{red}hello{reset}{bold}{italic}{red} {reset}{italic}{strikethrough}{abcdef}world{reset}{abcdef} asdf{bold}!{reset}",
- bold = Ansi::BOLD,
- italic = Ansi::ITALIC,
- underlined = Ansi::UNDERLINED,
- red = Ansi::rgb(ChatFormatting::RED.color.unwrap()),
- reset = Ansi::RESET,
- strikethrough = Ansi::STRIKETHROUGH,
- abcdef = Ansi::rgb(TextColor::parse("#abcdef".to_string()).unwrap().value),
- )
- );
-}
-
-#[test]
-fn component_from_string() {
- let j: Value = serde_json::from_str("\"foo\"").unwrap();
- let component = Component::deserialize(&j).unwrap();
- assert_eq!(component.to_ansi(None), "foo");
-}