<commit_before>/* eslint-env node, mocha */

import chai from 'chai'
import spies from 'chai-spies'
import Nativetable from '../src/scripts/nativetable/nativetable'

describe('Nativetable', () => {
  let nt

  chai.use(spies)
  chai.should()

  before(() => {
    global.btoa = () => '2U3I3O3I3'
  })

  beforeEach(() => {
    global.document = {
      getElementById() {
        return {
          innerHTML: ''
        }
      }
    }

    nt = new Nativetable('id')
    nt.sources = [
      {
        id: 12,
        name: 'bob',
        lastname: 'rob',
        age: 81,
        man: true
      },
      {
        id: 20,
        name: 'sarah',
        age: 29,
        man: false,
        brother: 3
      }
    ]
  })

  describe('#constructor', () => {
    before(() => {
      chai.spy.on(Nativetable.prototype, 'draw')
    })

    it('should call draw method on init', () => {
      nt = new Nativetable('id')
      nt.draw.should.have.been.called()
    })

    it('should init source with empty array when no options is passed', () => {
      nt = new Nativetable('id')
      nt.sources.should.be.an.instanceof(Array)
      nt.sources.should.be.empty
    })

    it('should init columns with array of keys string when no options is passed', () => {
      nt.sources.should.be.an.instanceof(Array)
      nt.sources.should.not.be.empty
    })

    it('should throw a TypeError if incorrect parameter is passed', () => {
      let test = () => {
        const t = new Nativetable(2) /* eslint-env node, mocha */
      }

      test.should.throw(TypeError)
    })

    it('should throw a TypeError if null is returned by getElementById for the given id', () => {
      global.document.getElementById = () => { return null }
      let test = () => {
        const t = new Nativetable('yolo') /* eslint-env node, mocha */<commit_msg>change eslint rules for one test<commit_after>/* eslint-env node, mocha */

import chai from 'chai'
import spies from 'chai-spies'
import Nativetable from '../src/scripts/nativetable/nativetable'

describe('Nativetable', () => {
  let nt

  chai.use(spies)
  chai.should()

  before(() => {
    global.btoa = () => '2U3I3O3I3'
  })

  beforeEach(() => {
    global.document = {
      getElementById() {
        return {
          innerHTML: ''
        }
      }
    }

    nt = new Nativetable('id')
    nt.sources = [
      {
        id: 12,
        name: 'bob',
        lastname: 'rob',
        age: 81,
        man: true
      },
      {
        id: 20,
        name: 'sarah',
        age: 29,
        man: false,
        brother: 3
      }
    ]
  })

  describe('#constructor', () => {
    before(() => {
      chai.spy.on(Nativetable.prototype, 'draw')
    })

    it('should call draw method on init', () => {
      nt = new Nativetable('id')
      nt.draw.should.have.been.called()
    })

    it('should init source with empty array when no options is passed', () => {
      nt = new Nativetable('id')
      nt.sources.should.be.an.instanceof(Array)
      nt.sources.should.be.empty
    })

    it('should init columns with array of keys string when no options is passed', () => {
      nt.sources.should.be.an.instanceof(Array)
      nt.sources.should.not.be.empty
    })

    it('should throw a TypeError if incorrect parameter is passed', () => {
      let test = () => {
        new Nativetable(2) // eslint-disable-line no-new
      }

      test.should.throw(TypeError)
    })

    it('should throw a TypeError if null is returned by getElementById for the given id', () => {
      global.document.getElementById = () => { return null }
      let test = () => {
        new Nativetable('yolo') // eslint-disable-line no-new
{'fraction_non_alphanumeric': 0.14965986394557823, 'fraction_numerical': 0.00816326530612245, 'mean_word_length': 2.0480928689883915, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2315679', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1170, 'n_words': 285}