package com.karateca.injecttest;

import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;

public class InjectTestActionTest extends LightCodeInsightFixtureTestCase {

  @Override
  protected String getTestDataPath() {
    return "testdata";
  }

  private void whenYouRunTheAction() {
    myFixture.performEditorAction("com.karateca.injecttest.InjectTestAction");
  }

  public void testInjectsES5NoParams() {
    myFixture.configureByFiles("inject-no-params-es5-before.js");

    whenYouRunTheAction();

    myFixture.checkResultByFile(
        "inject-no-params-es5-before.js",
        "inject-no-params-es5-after.js", false);
  }

  public void testInjectES5WithParams() {
    // Given that inject() has params.
    myFixture.configureByFile("inject-with-params-es5-before.js");

    whenYouRunTheAction();

    myFixture.checkResultByFile(
        "inject-with-params-es5-before.js",
        "inject-with-params-es5-after.js", false);
  }
}

@@ -267,119 +267,159 @@
 %0A  p
-rivate void whenYouRunTheAction() %7B%0A    myFixture.performEditorAction(%22com.karateca.injecttest.InjectTestAction
+ublic void testInjectsES5NoParams() %7B%0A    // inject() has no params.%0A    runActionTest(%22inject-no-params-es5-before.js%22, %22inject-no-params-es5-after.js
 %22);%0A
@@ -439,38 +439,39 @@
  void testInject
-s
 ES5
-No
+With
 Params() %7B%0A    m
@@ -473,34 +473,49 @@
     
-myFixture.configureByFil
+// inject() has params.%0A    runActionT
 es
+t
 (%22in
@@ -511,34 +511,36 @@
 ionTest(%22inject-
-no
+with
 -params-es5-befo
@@ -549,80 +549,161 @@
 .js%22
-);%0A%0A    whenYouRunTheA
+, %22inject-with-params-es5-after.js%22);%0A  %7D%0A%0A  public void testIgnoresWithoutSele
 ction()
-;%0A
+ %7B
 %0A    
-myFixture.checkResultByFile(%0A       
+// No selection changes nothing.%0A    String beforeAndAfter =
  %22in
@@ -699,34 +699,36 @@
 After = %22inject-
-no
+with
 -params-es5-befo
@@ -727,154 +727,142 @@
 es5-
-before
+after
 .js%22
-,
+;
 %0A    
-    %22inject-no-params-es5-after.js%22, false);%0A  %7D%0A%0A  public void testInjectES5WithParams() %7B%0A    // Given that inject() has params.
+runActionTest(beforeAndAfter, beforeAndAfter);%0A  %7D%0A%0A  private void runActionTest(String fileBefore, String fileAfter) %7B
 %0A   
@@ -891,51 +891,28 @@
 File
-(%22inject-with-params-es5-b
+s(fileB
 efore
-.js%22
 );%0A%0A    
 when
@@ -911,28 +911,80 @@
     
-whenYouRunThe
+myFixture.performEditorAction(%22com.karateca.injecttest.InjectTest
 Action
-(
+%22
 );%0A%0A
@@ -1019,94 +1019,29 @@
 ile(
-%0A        %22inject-with-params-es5-before.js%22,%0A        %22inject-with-params-es5-after.js%22
+fileBefore, fileAfter
 , fa

refactor test, add coverage for no selection