<commit_before>import { UnitTest, assert } from '@ephox/bedrock';
import { Hierarchy, Element } from '@ephox/sugar';
import { Obj } from '@ephox/katamari';
import DomDescent from 'ephox/phoenix/api/dom/DomDescent';

UnitTest.test('DomDescentTest', function () {

  var root = Element.fromHtml(
    '<div>\n' +
    '<p>This <span>first</span> thing I do</p>' +
    '<table>\n  <tbody>\n  <tr>\n  <td>Hi</td>\n  </tr>\n  </tbody>\n  </table>\n' +
    '</div>'
  );

  var toRef = function (v, k) {
    return {
      k: k,
      v: {
        element: Hierarchy.follow(root, v).getOrDie('Could not find path: ' + v + ' for key: ' + k),
        path: v
      }
    };
  };

  var refs = Obj.tupleMap({
    'div': [],
    'p': [1],
    'span': [1].concat([1]),
    'first': [1, 1].concat([0]),
    'table': [2],
    'td': [2, 1, 1, 1],
    'tdtext': [2, 1, 1, 1, 0]
  }, toRef);<commit_msg>TINY-1753: Fixed type errors caused by typing of Obj<commit_after>import { UnitTest, assert } from '@ephox/bedrock';
import { Hierarchy, Element } from '@ephox/sugar';
import { Obj } from '@ephox/katamari';
import DomDescent from 'ephox/phoenix/api/dom/DomDescent';

UnitTest.test('DomDescentTest', function () {

  var root = Element.fromHtml(
    '<div>\n' +
    '<p>This <span>first</span> thing I do</p>' +
    '<table>\n  <tbody>\n  <tr>\n  <td>Hi</td>\n  </tr>\n  </tbody>\n  </table>\n' +
    '</div>'
  );

  var toRef = function (v: number[], k: string) {
    return {
      element: Hierarchy.follow(root, v).getOrDie('Could not find path: ' + v + ' for key: ' + k),
      path: v
    };
  };

  var refs = Obj.map({
    'div': [],
    'p': [1],
    'span': [1].concat([1]),
    'first': [1, 1].concat([0]),
    'table': [2],
    'td': [2, 1, 1, 1],
    'tdtext': [2, 1, 1, 1, 0]
  }, toRef);
{'fraction_non_alphanumeric': 0.225517627308338, 'fraction_numerical': 0.020145495243424735, 'mean_word_length': 2.7172557172557172, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '1442120', 'n_tokens_mistral': 732, 'n_tokens_neox': 725, 'n_words': 172}