<commit_before>import {} from 'babel/register'
import { expect } from 'chai'
import DomPointer from '../index'
import { createElement } from './util'

const complies = (dp) => {
  expect(
      [...dp.refs.keys()]
  ).eql(
      [':0', ':0:0', ':0:0:0', ':0:0:1']
  )

  expect(dp.refs.get(':0')).eql(dp.el
          .firstChild
  )

  expect(dp.refs.get(':0:0')).eql(dp.el
          .firstChild
          .firstChild
  )

  expect(dp.refs.get(':0:0:0')).eql(dp.el
          .firstChild
          .firstChild
          .firstChild
  )

  expect(dp.refs.get(':0:0:1')).eql(dp.el
          .firstChild
          .firstChild
          .childNodes[1]
  )
}

describe('DomPointer', () => {
  const html = `
    <div>
      <div>
        <h3 title="H3"></h3>
        <h6></h6>
      </div>
    </div>`
  const targetEl = document.getElementById('target')

  it('create()', () => {
    DomPointer.create(createElement(html))
  })

  it('fromHTML()', () => {
    DomPointer.fromHTML(html)
  })

  it('path()', () => {
    const dp = DomPointer.fromHTML(html)
    // gah when to do it?
    // normally if the element is empty you'll want to wait for all info first.
    // the elements
    dp.setElement(targetEl)
    dp.render()
    expect(dp.path(dp.refs.get(':0'))).eql(':0')
    expect(dp.path(dp.refs.get(':0:0'))).eql(':0:0')
    expect(dp.path(dp.refs.get(':0:0:0'))).eql(':0:0:0')
    expect(dp.path(dp.refs.get(':0:0:1'))).eql(':0:0:1')
  })

  it('paths()', () => {

    const dp = DomPointer.fromHTML(html)
    dp.setElement(targetEl)
    dp.render()

    const refs = [
      dp.refs.get(':0'),<commit_msg>clean<commit_after>import {} from 'babel/register'
import { expect } from 'chai'
import DomPointer from '../index'
import { createElement } from './util'

const complies = (dp) => {
  expect(
      [...dp.refs.keys()]
  ).eql(
      [':0', ':0:0', ':0:0:0', ':0:0:1']
  )

  expect(dp.refs.get(':0')).eql(dp.el
          .firstChild
  )

  expect(dp.refs.get(':0:0')).eql(dp.el
          .firstChild
          .firstChild
  )

  expect(dp.refs.get(':0:0:0')).eql(dp.el
          .firstChild
          .firstChild
          .firstChild
  )

  expect(dp.refs.get(':0:0:1')).eql(dp.el
          .firstChild
          .firstChild
          .childNodes[1]
  )
}

describe('DomPointer', () => {
  const html = `
    <div>
      <div>
        <h3 title="H3"></h3>
        <h6></h6>
      </div>
    </div>`
  const targetEl = document.getElementById('target')

  it('create()', () => {
    DomPointer.create(createElement(html))
  })

  it('fromHTML()', () => {
    DomPointer.fromHTML(html)
  })

  it('path()', () => {
    const dp = DomPointer.fromHTML(html)
    dp.setElement(targetEl)
    dp.render()
    expect(dp.path(dp.refs.get(':0'))).eql(':0')
    expect(dp.path(dp.refs.get(':0:0'))).eql(':0:0')
    expect(dp.path(dp.refs.get(':0:0:0'))).eql(':0:0:0')
    expect(dp.path(dp.refs.get(':0:0:1'))).eql(':0:0:1')
  })

  it('paths()', () => {

    const dp = DomPointer.fromHTML(html)
    dp.setElement(targetEl)
    dp.render()

    const refs = [
      dp.refs.get(':0'),
{'fraction_non_alphanumeric': 0.22665369649805447, 'fraction_numerical': 0.027885862516212712, 'mean_word_length': 2.4277777777777776, 'pattern_counts': {'":': 0, '<': 19, '<?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': '1309118', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1212, 'n_words': 168}