<commit_before>'use babel'

import * as fs from 'fs'
import * as path from 'path'
import { waitsForAsync, waitsForAsyncRejection } from './spec-helpers'
const helpersOfHelpers = require('../src/helpers')
const helpers = require('../src/index')

const mixedIndentFile = path.join(__dirname, 'fixtures', 'mixedIndent.txt')
const somethingFile = path.join(__dirname, 'fixtures', 'something.js')
const packageJsonPath = fs.realpathSync(`${__dirname}/../package.json`)

describe('linter helpers', function () {
  describe('::rangeFromLineNumber', function () {
    it('cries when invalid textEditor is passed', () =>
      expect(() =>
        helpers.rangeFromLineNumber()
      ).toThrow()
    )

    it('returns a range pointing at file start if no or invalid line is provided', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        expect(helpers.rangeFromLineNumber(textEditor)).toEqual([[0, 0], [0, 30]])
        expect(helpers.rangeFromLineNumber(textEditor, -1)).toEqual([[0, 0], [0, 30]])
        expect(helpers.rangeFromLineNumber(textEditor, 'a')).toEqual([[0, 0], [0, 30]])
      })
    )

    it('ignores an invalid starting column', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        expect(helpers.rangeFromLineNumber(textEditor, 7, -1)).toEqual([[7, 0], [7, 43]])
        expect(helpers.rangeFromLineNumber(textEditor, 7, 'a')).toEqual([[7, 0], [7, 43]])
      })
    )

    it('returns a range (array) with some valid points', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        const range = helpers.rangeFromLineNumber(textEditor, 7)
        expect(range instanceof Array).toBe(true)
        expect(range[0] instanceof Array).toBe(true)
        expect(range[1] instanceof Array).toBe(true)
        expect(range[0][0]).toEqual(7)
        expect(range[0][1]).toEqual(0)
        expect(range[1][0]).toEqual(7)
        expect(range[1][1]).toEqual(43)
      })
    )

    it('returns a range (array) with some valid points and provided colStart', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        const range = helpers.rangeFromLineNumber(textEditor, 7, 4)
        expect(range instanceof Array).toBe(true)
        expect(range[0] instanceof Array).toBe(true)
        expect(range[1] instanceof Array).toBe(true)
        expect(range[0][0]).toEqual(7)
        expect(range[0][1]).toEqual(4)
        expect(range[1][0]).toEqual(7)
        expect(range[1][1]).toEqual(43)
      })
    )

    it('cries when colStart is greater than line length', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()<commit_msg>:white_check_mark: Update specs to match latest behavior<commit_after>'use babel'

import * as fs from 'fs'
import * as path from 'path'
import { waitsForAsync, waitsForAsyncRejection } from './spec-helpers'
const helpersOfHelpers = require('../src/helpers')
const helpers = require('../src/index')

const mixedIndentFile = path.join(__dirname, 'fixtures', 'mixedIndent.txt')
const somethingFile = path.join(__dirname, 'fixtures', 'something.js')
const packageJsonPath = fs.realpathSync(`${__dirname}/../package.json`)

describe('linter helpers', function () {
  describe('::rangeFromLineNumber', function () {
    it('cries when invalid textEditor is passed', () =>
      expect(() =>
        helpers.rangeFromLineNumber()
      ).toThrow()
    )

    it('returns a range pointing at file start if no or invalid line is provided', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        expect(helpers.rangeFromLineNumber(textEditor)).toEqual([[0, 0], [0, 7]])
        expect(helpers.rangeFromLineNumber(textEditor, -1)).toEqual([[0, 0], [0, 7]])
        expect(helpers.rangeFromLineNumber(textEditor, 'a')).toEqual([[0, 0], [0, 7]])
      })
    )

    it('ignores an invalid starting column', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        expect(helpers.rangeFromLineNumber(textEditor, 7, -1)).toEqual([[7, 0], [7, 2]])
        expect(helpers.rangeFromLineNumber(textEditor, 7, 'a')).toEqual([[7, 0], [7, 2]])
      })
    )

    it('returns a range (array) with some valid points', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        const range = helpers.rangeFromLineNumber(textEditor, 7)
        expect(range instanceof Array).toBe(true)
        expect(range[0] instanceof Array).toBe(true)
        expect(range[1] instanceof Array).toBe(true)
        expect(range[0][0]).toEqual(7)
        expect(range[0][1]).toEqual(0)
        expect(range[1][0]).toEqual(7)
        expect(range[1][1]).toEqual(2)
      })
    )

    it('returns a range (array) with some valid points and provided colStart', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
        const range = helpers.rangeFromLineNumber(textEditor, 7, 4)
        expect(range instanceof Array).toBe(true)
        expect(range[0] instanceof Array).toBe(true)
        expect(range[1] instanceof Array).toBe(true)
        expect(range[0][0]).toEqual(7)
        expect(range[0][1]).toEqual(4)
        expect(range[1][0]).toEqual(7)
        expect(range[1][1]).toEqual(11)
      })
    )

    it('cries when colStart is greater than line length', () =>
      waitsForAsync(async function () {
        await atom.workspace.open(somethingFile)
        const textEditor = atom.workspace.getActiveTextEditor()
{'fraction_non_alphanumeric': 0.145044319097502, 'fraction_numerical': 0.019016921837228043, 'mean_word_length': 3.4744051910598412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5789443', 'n_tokens_mistral': 1867, 'n_tokens_neox': 1875, 'n_words': 389}