package com.karateca.ddescriber.model;

import com.intellij.find.FindResult;
import com.karateca.ddescriber.BaseTestCase;

import java.util.List;

/**
 * @author Andres Dominguez.
 */
public class JasmineFinderTest extends BaseTestCase {

  public void testFindAll() throws Exception {
    List<FindResult> findResults = whenYouFindTestsForJsFile("jasmineTestBefore.js");

    // Then ensure there are 9 tests and suites.
    assertEquals(9, findResults.size());
  }

  public void testWithCaretAtTheTop() {
    List<FindResult> findResults = whenYouFindTestsForJsFile("jasmineTestCaretTop.js");

    // Then ensure there are 6 tests and suites.
    assertEquals(7, findResults.size());
  }

  public void testShouldFindTestsWithTrickyText() {
    List<FindResult> findResults = whenYouFindTestsForJsFile("jasmineWithWeirdRegularExpressions.js");

    // Then ensure all the tests were found.
    assertEquals(11, findResults.size());
  }

  private List<FindResult> whenYouFindTestsForJsFile(String fileName) {
    prepareScenarioWithTestFile(fileName);
    jasmineFinder.findAll();
    return jasmineFinder.getFindResults();
  }
}

@@ -144,45 +144,8 @@
 t;%0A%0A
-/**%0A * @author Andres Dominguez.%0A */%0A
 publ
@@ -242,16 +242,173 @@
 ption %7B%0A
+    findsAllTests(%22jasmine1/jasmineTestBefore.js%22);%0A    findsAllTests(%22jasmine2/jasmineTestBefore.js%22);%0A  %7D%0A%0A  private void findsAllTests(String fileName) %7B%0A
     List
@@ -464,30 +464,16 @@
 ile(
-%22jasmineTestBefore.js%22
+fileName
 );%0A%0A
@@ -603,24 +603,227 @@
 tTheTop() %7B%0A
+    findsTestsWithCaretAtTheTop(%22jasmine1/jasmineTestCaretTop.js%22);%0A    findsTestsWithCaretAtTheTop(%22jasmine2/jasmineTestCaretTop.js%22);%0A  %7D%0A%0A  private void findsTestsWithCaretAtTheTop(String fileName) %7B%0A
     List%3CFin
@@ -875,32 +875,16 @@
 ile(
-%22jasmineTestCaretTop.js%22
+fileName
 );%0A%0A
@@ -1038,66 +1038,123 @@
     
-List%3CFindResult%3E findResults = whenYouF
+findsTestsWithTrickyText(%22jasmine1/jasmineWithWeirdRegularExpressions.js%22);%0A    f
 ind
+s
 Tests
-ForJsFile(%22
+WithTrickyText(%22jasmine2/
 jasm
@@ -1189,16 +1189,161 @@
 ns.js%22);
+%0A  %7D%0A%0A  private void findsTestsWithTrickyText(String fileName) %7B%0A    List%3CFindResult%3E findResults = whenYouFindTestsForJsFile(%0A        fileName);
 %0A%0A    //

Add scenarios for jasmine 1, 2