<commit_before>import { expect } from 'chai'
import path from 'path'

import { run } from '../src/jq'
import { FILTER_UNDEFINED_ERROR } from '../src/command'
import { INVALID_PATH_ERROR, INVALID_JSON_PATH_ERROR } from '../src/utils'

const PATH_ROOT = path.join(__dirname, '..')
const PATH_ASTERISK_FIXTURE = path.join(PATH_ROOT, 'src', '*.js')
const PATH_FIXTURES = path.join('test', 'fixtures')

const PATH_JSON_FIXTURE = path.join(PATH_FIXTURES, '1.json')
const PATH_JS_FIXTURE = path.join(PATH_FIXTURES, '1.js')
const PATH_LARGE_JSON_FIXTURE = path.join(PATH_FIXTURES, 'large.json')
const PATH_VARIABLE_JSON_FIXTURE = path.join(PATH_FIXTURES, 'var.json')

const FIXTURE_JSON = require('./fixtures/1.json')
const FIXTURE_JSON_STRING = JSON.stringify(FIXTURE_JSON, null, 2)

const FILTER_VALID = '.repository.type'
const FILTER_INVALID = 'invalid'
const FILTER_WITH_VARIABLE =
  '[ . as $x | .user[] | {"user": ., "site": $x.site} ]'

const ERROR_INVALID_FILTER = /invalid/

describe('jq core', () => {
  it('should fulfill its promise', done => {
    run(FILTER_VALID, PATH_JSON_FIXTURE)
      .then(output => {
        expect(output).to.be.a('string')
        done()
      })
      .catch(error => {
        done(error)
      })
  })

  it('should pass on an empty filter', done => {
    run('', PATH_JSON_FIXTURE)
      .then(output => {
        const normalizedOutput = output.replace(/\r\n/g, '\n')
        expect(normalizedOutput).to.equal(FIXTURE_JSON_STRING)
        done()
      })
      .catch(error => {
        done(error)
      })
  })

  it('should pass on a null filter', done => {
    run(null, PATH_JSON_FIXTURE)
      .then(output => {
        expect(output).to.equal('null')
        done()<commit_msg>fix(jq-core): check test output value<commit_after>import { expect } from 'chai'
import path from 'path'

import { run } from '../src/jq'
import { FILTER_UNDEFINED_ERROR } from '../src/command'
import { INVALID_PATH_ERROR, INVALID_JSON_PATH_ERROR } from '../src/utils'

const PATH_ROOT = path.join(__dirname, '..')
const PATH_ASTERISK_FIXTURE = path.join(PATH_ROOT, 'src', '*.js')
const PATH_FIXTURES = path.join('test', 'fixtures')

const PATH_JSON_FIXTURE = path.join(PATH_FIXTURES, '1.json')
const PATH_JS_FIXTURE = path.join(PATH_FIXTURES, '1.js')
const PATH_LARGE_JSON_FIXTURE = path.join(PATH_FIXTURES, 'large.json')
const PATH_VARIABLE_JSON_FIXTURE = path.join(PATH_FIXTURES, 'var.json')

const FIXTURE_JSON = require('./fixtures/1.json')
const FIXTURE_JSON_STRING = JSON.stringify(FIXTURE_JSON, null, 2)

const FILTER_VALID = '.repository.type'
const FILTER_INVALID = 'invalid'
const FILTER_WITH_VARIABLE =
  '[ . as $x | .user[] | {"user": ., "site": $x.site} ]'

const ERROR_INVALID_FILTER = /invalid/

describe('jq core', () => {
  it('should fulfill its promise', done => {
    run(FILTER_VALID, PATH_JSON_FIXTURE)
      .then(output => {
        expect(output).to.equal('"git"')
        done()
      })
      .catch(error => {
        done(error)
      })
  })

  it('should pass on an empty filter', done => {
    run('', PATH_JSON_FIXTURE)
      .then(output => {
        const normalizedOutput = output.replace(/\r\n/g, '\n')
        expect(normalizedOutput).to.equal(FIXTURE_JSON_STRING)
        done()
      })
      .catch(error => {
        done(error)
      })
  })

  it('should pass on a null filter', done => {
    run(null, PATH_JSON_FIXTURE)
      .then(output => {
        expect(output).to.equal('null')
        done()
{'fraction_non_alphanumeric': 0.15657439446366783, 'fraction_numerical': 0.002306805074971165, 'mean_word_length': 3.453145057766367, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 21, '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': '2797697', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1221, 'n_words': 239}