/*
 * This file is part of adventure, licensed under the MIT License.
 *
 * Copyright (c) 2017-2021 KyoriPowered
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package net.kyori.adventure.text;

import java.util.UUID;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.event.HoverEvent;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

class ComponentContainsTest {
  @Test
  public void testOf() {
    final Component c0 = Component.text("best!");
    final Component c1 = Component.text()
      .append(Component.text("Nero "))
      .append(Component.text(" are the ").append(c0))
      .build();

    assertTrue(c1.contains(c0));
  }

  @Test
  public void testOfHoverShowText() {
    final Component c0 = Component.text("A great EDM trio");
    final Component c1 = Component.text()
      .append(Component.text("Nero ").hoverEvent(c0))
      .append(Component.text(" are the best!"))
      .build();

    assertTrue(c1.contains(c0));
  }

  @Test
  public void testOfHoverShowEntity() {
    final Component c0 = Component.text("Joe Ray");
    final Component c1 = Component.text()
      .append(Component.text("One member").hoverEvent(HoverEvent.showEntity(Key.key("minecraft:player"), UUID.randomUUID(), c0)))
      .append(Component.text(" launched a solo project in 2017."))
      .build();

    assertTrue(c1.contains(c0));
  }
}

@@ -1715,36 +1715,108 @@
 .contains(c0));%0A
+    assertTrue(c1.contains(Component.text(%22best!%22), Component.EQUALS));%0A
   %7D%0A
-
 %0A  @Test%0A  publi
@@ -2097,24 +2097,107 @@
 tains(c0));%0A
+    assertTrue(c1.contains(Component.text(%22A great EDM trio%22), Component.EQUALS));%0A
   %7D%0A%0A  @Test
@@ -2537,32 +2537,32 @@
      .build();%0A%0A
-
     assertTrue(c
@@ -2574,18 +2574,92 @@
 tains(c0));%0A
+    assertTrue(c1.contains(Component.text(%22Joe Ray%22), Component.EQUALS));%0A
   %7D%0A%7D%0A

Check both forms of component equality