<commit_before>/* globals afterEach, beforeEach, describe, it, expect, jasmine */

const build = require('../../lib/build')
const util = require('../test-utils/util.js')

const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL

describe('build', () => {
  const mockDir = util.mockDir

  beforeEach(() => {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
  })
  afterEach(() => {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout
  })

  describe('development', () => {
    it('should transform js', (done) => {
      const results = build({
        config: {},
        files: [[`${mockDir}/index.js`]]
      })

      results[0]
        .then((buf) => {
          expect(buf.toString().indexOf('MockTestComponentUniqueName')).to.not.equal(-1)
          done()
        })
        .catch(done)
    })

    it('should transform css', async () => {
      const results = build({
        config: {},
        files: [[`${mockDir}/index.css`]]
      })

      const result = await results[0]
      const css = result.css
      expect(css.indexOf('criticalClass')).toBeGreaterThan(-1)
    })
  })

  describe('production', () => {
    it('should transform and minify js', async () => {
      const results = build({
        config: {},
        env: 'production',
        files: [
          [`${mockDir}/index.js`],
          [`${mockDir}/index.css`]
        ],
        minify: true
      })

      const output = await Promise.all(results)

      expect(output[0].toString().indexOf('MockTestComponentUniqueName')).not.toBe(-1)
      expect(output[1].css.indexOf('criticalClass')).not.toBe(-1)
    })
  })
})<commit_msg>test(build): Update build tests to use new api<commit_after>/* globals afterEach, beforeEach, describe, it, expect, jasmine */

const build = require('../../lib/build')
const util = require('../test-utils/util.js')

const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL

describe('build', () => {
  const mockDir = util.mockDir

  beforeEach(() => {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
  })
  afterEach(() => {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout
  })

  describe('development', () => {
    it('should transform js', async () => {
      const [result] = await build({
        config: {},
        files: [[`${mockDir}/index.js`]]
      })

      console.log(result)

      expect(result.toString().indexOf('MockTestComponentUniqueName')).not.toBe(-1)
    })

    it('should transform css', async () => {
      const [result] = await build({
        config: {},
        files: [[`${mockDir}/index.css`]]
      })

      const css = result.css
      expect(css.indexOf('criticalClass')).toBeGreaterThan(-1)
    })
  })

  describe('production', () => {
    it('should transform and minify js', async () => {
      const output = await build({
        config: {},
        env: 'production',
        files: [
          [`${mockDir}/index.js`],
          [`${mockDir}/index.css`]
        ],
        minify: true
      })

      expect(output[0].toString().indexOf('MockTestComponentUniqueName')).not.toBe(-1)
      expect(output[1].css.indexOf('criticalClass')).not.toBe(-1)
    })
  })
})
{'fraction_non_alphanumeric': 0.17955271565495207, 'fraction_numerical': 0.0076677316293929714, 'mean_word_length': 2.6113033448673586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '5287027', 'n_tokens_mistral': 964, 'n_tokens_neox': 941, 'n_words': 169}