package integration.customcommands;

import com.codeborne.selenide.commands.Commands;
import integration.IntegrationTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static integration.customcommands.MyFramework.$_;
import static integration.customcommands.MyFramework.quadrupleClickCounter;
import static integration.customcommands.MyFramework.tripleClickCounter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class CustomCommandsTest extends IntegrationTest {
  @Before
  public void setUpFramework() {
    MyFramework.setUp();
    tripleClickCounter.set(0);
    quadrupleClickCounter.set(0);
  }
  
  @Test
  public void userCanAddAnyCustomCommandsToSelenide() {
    $_("#valid-image").tripleClick().tripleClick().tripleClick().click();
    $_("#invalid-image").tripleClick().quadrupleClick();
    
    assertTrue("Can also use standard Selenide methods", $_("#valid-image img").isImage());
    assertFalse("Can also use standard Selenide methods", $_("#invalid-image img").isImage());
    
    assertEquals(4, tripleClickCounter.get());
    assertEquals(1, quadrupleClickCounter.get());
  }

  @Before
  public void openTestPage() {
    openFile("page_with_images.html");
  }

  @After
  public void resetSelenideDefaultCommands() {
    Commands.collection.resetDefaults();
  }
}

@@ -206,287 +206,104 @@
 tic 
-integration.cust
+c
 om
+.
 co
-mmands.MyFramework.$_;%0Aimport static integration.customcommands.MyFramework.quadrupleClickCounter;%0Aimport static integration.customcommands.MyFramework.tripleClickCounter;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse
+deborne.selenide.Condition.visible;%0Aimport static integration.customcommands.MyFramework.*
 ;%0Aim
@@ -331,26 +331,17 @@
 .Assert.
-assertTrue
+*
 ;%0A%0Apubli
@@ -769,34 +769,34 @@
  standard Seleni
-de
+um
  methods%22, $_(%22#
@@ -807,37 +807,41 @@
 d-image img%22).is
-Image
+Displayed
 ());%0A    assertF
@@ -843,12 +843,11 @@
 sert
-Fals
+Tru
 e(%22C
@@ -917,14 +917,16 @@
 ).is
-Image(
+(visible
 ));%0A

fix test for htmlunit