<commit_before>import describeTarget from '../src/utils/describeTarget'

const base = {
  target: {
    classList: {
      entries() {
        return []
      }
    }
  }
}



describe('describeTarget', () => {
  test('with event from normal button with id', () => {
    const buttonWithId = {
      ...base,
      target: {
        ...base.target,
        localName: 'button',
        innerText: 'Make purchase',
        attributes: {
          id: {
            value: 'abc'
          }
        },
      }
    }
    const result = describeTarget(buttonWithId)
    expect(result).toEqual({
      text: 'Make purchase',
      cssSelector: 'button#abc'
    })
  })

  test('with event from normal button with class name', () => {
    const buttonWithClassname = {
      ...base,
      target: {
        ...base.target,
        localName: 'button',
        attributes: {},
        classList: {
          entries() {
            return [
              [null, 'primary'],
              [null, 'mr4']
            ]
          }
        }
      }
    }
    const result = describeTarget(buttonWithClassname)
    expect(result).toEqual({
      cssSelector: 'button.primary.mr4'
    })
  })

  test('with event with data-track attribute', () => {
    const tracked = {
      ...base,
      target: {
        ...base.target,
        localName: 'a',
        innerText: 'Buy!',
        attributes: {
          id: {
            value: 'purchase'
          },
          'data-track': {
            value: 'Make purchase'
          }
        },
        classList: {
          entries() {
            return []
          }
        }
      }
    }
    const result = describeTarget(tracked)
    expect(result).toEqual({
      text: 'Buy!',
      eventName: 'Make purchase',
      cssSelector: 'a#purchase'
    })
  })
})<commit_msg>whitespace<commit_after>import describeTarget from '../src/utils/describeTarget'

const base = {
  target: {
    classList: {
      entries() {
        return []
      }
    }
  }
}


describe('describeTarget', () => {
  test('with event from normal button with id', () => {
    const buttonWithId = {
      ...base,
      target: {
        ...base.target,
        localName: 'button',
        innerText: 'Make purchase',
        attributes: {
          id: {
            value: 'abc'
          }
        },
      }
    }
    const result = describeTarget(buttonWithId)
    expect(result).toEqual({
      text: 'Make purchase',
      cssSelector: 'button#abc'
    })
  })

  test('with event from normal button with class name', () => {
    const buttonWithClassname = {
      ...base,
      target: {
        ...base.target,
        localName: 'button',
        attributes: {},
        classList: {
          entries() {
            return [
              [null, 'primary'],
              [null, 'mr4']
            ]
          }
        }
      }
    }
    const result = describeTarget(buttonWithClassname)
    expect(result).toEqual({
      cssSelector: 'button.primary.mr4'
    })
  })

  test('with event with data-track attribute', () => {
    const tracked = {
      ...base,
      target: {
        ...base.target,
        localName: 'a',
        innerText: 'Buy!',
        attributes: {
          id: {
            value: 'purchase'
          },
          'data-track': {
            value: 'Make purchase'
          }
        },
        classList: {
          entries() {
            return []
          }
        }
      }
    }
    const result = describeTarget(tracked)
    expect(result).toEqual({
      text: 'Buy!',
      eventName: 'Make purchase',
      cssSelector: 'a#purchase'
    })
  })
})
{'fraction_non_alphanumeric': 0.14057331863285558, 'fraction_numerical': 0.0011025358324145535, 'mean_word_length': 1.4421265141318977, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3101701', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1046, 'n_words': 212}