<commit_before>const path = require('path')
const config = require('../../lib/config')

const p = pathname => {
  return path.relative(process.cwd(), pathname).replace(/\\/g, '/')
}

describe('Config', () => {
  it('loads js file', () => {
    config('test/fixtures/normal.config.js')
  })

  it('loads json file', () => {
    config('test/fixtures/test.config.json')
  })

  it('throws if try loading other file', () => {
    expect(() => config('test/fixtures/test.coffee'))
      .toThrowError(/test\.coffee is non-supported file format/)
  })

  it('resolves input/output paths besed on cwd', () => {
    const c = config('test/fixtures/normal.config.js')
    expect(p(c.input)).toBe('test/fixtures/src')
    expect(p(c.output)).toBe('test/fixtures/dist')
  })

  it('resolves paths in execute options based on cwd', () => {
    const c = config('test/fixtures/normal.config.js')
    const e = c.execute[0]
    expect(p(e.input)).toBe('test/fixtures/src/img/_assets/*.svg')
    expect(p(e.output)).toBe('test/fixtures/dist/img/share')
  })

  it('loads task file', () => {
    const c = config('test/fixtures/normal.config.js')
    expect(c.task.task1()).toBe('foo')
    expect(c.task.task2()).toBe('bar')
  })

  it('normalizes rules options', () => {
    const c = config('test/fixtures/normal.config.js')
    expect(typeof c.rules.png).toBe('object')
    expect(c.rules.png.task).toBe('imagemin')
  })
})<commit_msg>Tweak spec file<commit_after>const path = require('path')
const config = require('../../lib/config')

const read = pathname => {
  return config(path.join('test/fixtures', pathname))
}

// check
const p = pathname => {
  return path.relative(
    path.join(process.cwd(), 'test/fixtures'),
    pathname
  ).replace(/\\/g, '/')
}

describe('Config', () => {
  it('loads js file', () => {
    read('normal.config.js')
  })

  it('loads json file', () => {
    read('test.config.json')
  })

  it('throws if try loading other file', () => {
    expect(() => read('test.coffee'))
      .toThrowError(/test\.coffee is non-supported file format/)
  })

  it('resolves input/output paths besed on cwd', () => {
    const c = read('normal.config.js')
    expect(p(c.input)).toBe('src')
    expect(p(c.output)).toBe('dist')
  })

  it('resolves paths in execute options based on cwd', () => {
    const c = read('normal.config.js')
    const e = c.execute[0]
    expect(p(e.input)).toBe('src/img/_assets/*.svg')
    expect(p(e.output)).toBe('dist/img/share')
  })

  it('loads task file', () => {
    const c = read('normal.config.js')
    expect(c.task.task1()).toBe('foo')
    expect(c.task.task2()).toBe('bar')
  })

  it('normalizes rules options', () => {
    const c = read('normal.config.js')
    expect(typeof c.rules.png).toBe('object')
    expect(c.rules.png.task).toBe('imagemin')
  })
})
{'fraction_non_alphanumeric': 0.21720583007465338, 'fraction_numerical': 0.002132954141485958, 'mean_word_length': 3.3627906976744186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '2196378', 'n_tokens_mistral': 988, 'n_tokens_neox': 971, 'n_words': 168}