<commit_before>package com.karateca.ddescriber;

import java.util.List;

/**
 * @author <NAME>.
 */
public class HierarchyTest extends BaseTestCase {

  private Hierarchy getHierarchyForTestFile(String testFile) {
    prepareScenarioWithTestFile(testFile);
    jasmineFinder.findAll();

    return new Hierarchy(document, jasmineFinder.findResults, myFixture.getCaretOffset());
  }

  public void testGetClosest() throws Exception {
    // Given that the caret is under "inner it 2".
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestBefore.js");

    // When you find the closest test or fixture.
    TestFindResult closest = hierarchy.getClosest();

    // Then ensure the closest test is "inner it 2".
    assertEquals(28, closest.getLineNumber());
    assertEquals("        it('inner it 2', function () {", closest.lineText);
  }

  public void testGetUnitTestsForCurrentDescribe() throws Exception {
    // Given that the caret is under "inner it 2".
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestBefore.js");

    // When you the unit tests for the current describe.
    List<TestFindResult> elements = hierarchy.getUnitTestsForCurrentDescribe();

    // Then ensure all the 'its' in the current describe and the parents
    // are returned.
    assertEquals(5, elements.size());
    assertEquals("describe('top describe', function () {", elements.get(0).lineText);
    assertEquals("    ddescribe('inner describe', function () {", elements.get(1).lineText);
    assertEquals("        it('inner it 1', function () {", elements.get(2).lineText);
    assertEquals("        it('inner it 2', function () {", elements.get(3).lineText);
    assertEquals("        iit('inner it 3', function () {", elements.get(4).lineText);
  }

  public void testUnitTestsForCurrentDescribeAndCaretAtTheTop() {
    // Given that you have the caret at the top.
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestCaretTop.js");

    // When you get the unit tests.
    List<TestFindResult> elements = hierarchy.getUnitTestsForCurrentDescribe();

    // Then ensure the first level inside the top describe is returned.
    assertEquals(4, elements.size());
    int i = 0;
    assertEquals("describe('top describe', function () {", elements.get(i++).lineText);
    assertEquals("    it('first it', function () {", elements.get(i++).lineText);
    assertEquals("    it('second it', function () {", elements.get(i++).lineText);
    assertEquals("    ddescribe('inner describe', function () {", elements.get(i++).lineText);
  }

  public void testGetMarkedElements() {
    // Given that you have the caret at the top.
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestCaretTop.js");

    // When you get the marked elements.
    List<TestFindResult> elements = hierarchy.getMarkedElements();
<commit_msg>update tests for the new tostring<commit_after>package com.karateca.ddescriber;

import java.util.List;

/**
 * @author <NAME>.
 */
public class HierarchyTest extends BaseTestCase {

  private Hierarchy getHierarchyForTestFile(String testFile) {
    prepareScenarioWithTestFile(testFile);
    jasmineFinder.findAll();

    return new Hierarchy(document, jasmineFinder.findResults, myFixture.getCaretOffset());
  }

  public void testGetClosest() throws Exception {
    // Given that the caret is under "inner it 2".
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestBefore.js");

    // When you find the closest test or fixture.
    TestFindResult closest = hierarchy.getClosest();

    // Then ensure the closest test is "inner it 2".
    assertEquals(28, closest.getLineNumber());
    assertEquals("        it('inner it 2'", closest.getTestText());
  }

  public void testGetUnitTestsForCurrentDescribe() throws Exception {
    // Given that the caret is under "inner it 2".
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestBefore.js");

    // When you the unit tests for the current describe.
    List<TestFindResult> elements = hierarchy.getUnitTestsForCurrentDescribe();

    // Then ensure all the 'its' in the current describe and the parents
    // are returned.
    assertEquals(5, elements.size());
    assertEquals("describe('top describe'", elements.get(0).getTestText());
    assertEquals("    ddescribe('inner describe'", elements.get(1).getTestText());
    assertEquals("        it('inner it 1'", elements.get(2).getTestText());
    assertEquals("        it('inner it 2'", elements.get(3).getTestText());
    assertEquals("        iit('inner it 3'", elements.get(4).getTestText());
  }

  public void testUnitTestsForCurrentDescribeAndCaretAtTheTop() {
    // Given that you have the caret at the top.
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestCaretTop.js");

    // When you get the unit tests.
    List<TestFindResult> elements = hierarchy.getUnitTestsForCurrentDescribe();

    // Then ensure the first level inside the top describe is returned.
    assertEquals(4, elements.size());
    int i = 0;
    assertEquals("describe('top describe'", elements.get(i++).getTestText());
    assertEquals("    it('first it'", elements.get(i++).getTestText());
    assertEquals("    it('second it'", elements.get(i++).getTestText());
    assertEquals("    ddescribe('inner describe'", elements.get(i++).getTestText());
  }

  public void testGetMarkedElements() {
    // Given that you have the caret at the top.
    Hierarchy hierarchy = getHierarchyForTestFile("jasmineTestCaretTop.js");

    // When you get the marked elements.
    List<TestFindResult> elements = hierarchy.getMarkedElements();

{'fraction_non_alphanumeric': 0.12177650429799428, 'fraction_numerical': 0.0060888252148997134, 'mean_word_length': 3.968861209964413, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1077919', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1542, 'n_words': 439}