<commit_before>fs = require "fs"
path = require "path"
should = require "should"
gutil = require "gulp-util"
gcson = require "../"

require "mocha"

describe "gulp-cson", ->
  it "should parse cson to json", (done) ->
    myFunction = gcson()
    fakeFile = new gutil.File
      base: "test/fixtures"
      cwd: "test/"
      path: "test/fixtures/normal.cson"
      contents: fs.readFileSync path.join __dirname, "/fixtures/normal.cson"

    myFunction.once "data", (newFile) ->
      should.exist newFile
      should.exist newFile.contents
      should.equal newFile.path, 'test/fixtures/normal.json'
      String(newFile.contents).should.equal String fs.readFileSync path.join __dirname, "/expected/normal.json"
      done()

    myFunction.write fakeFile

  it "should return error on error", (done) ->
    myFunction = gcson()
    fakeFile = new gutil.File
      base: "test/fixtures"
      cwd: "test/"
      path: "test/fixtures/normal.cson"
      contents: fs.readFileSync path.join __dirname, "/fixtures/error.cson"

    myFunction.once "error", (err) ->
      should.exist err
      should.equal String(err.message), "[stdin]:12:1: error: unmatched }\n\u001b[1;31m}\u001b[0m\n\u001b[1;31m^\u001b[0m"

      done()

    myFunction.write fakeFile
<commit_msg>update error for cson 3.x<commit_after>fs = require 'fs'
path = require 'path'
should = require 'should'
gutil = require 'gulp-util'
gcson = require '../'

require 'mocha'

describe 'gulp-cson', ->
  it 'should parse cson to json', (done) ->
    myFunction = gcson()
    fakeFile = new gutil.File
      base: 'test/fixtures'
      cwd: 'test/'
      path: 'test/fixtures/normal.cson'
      contents: fs.readFileSync path.join __dirname, '/fixtures/normal.cson'

    myFunction.once 'data', (newFile) ->
      should.exist newFile
      should.exist newFile.contents
      should.equal newFile.path, 'test/fixtures/normal.json'
      String(newFile.contents).should.equal String fs.readFileSync path.join __dirname, '/expected/normal.json'
      done()

    myFunction.write fakeFile

  it 'should return error on error', (done) ->
    myFunction = gcson()
    fakeFile = new gutil.File
      base: 'test/fixtures'
      cwd: 'test/'
      path: 'test/fixtures/normal.cson'
      contents: fs.readFileSync path.join __dirname, '/fixtures/error.cson'

    myFunction.once 'error', (err) ->
      should.exist err
      should.equal err.name, 'SyntaxError'
      should.equal err.message, 'unmatched }'
      done()

    myFunction.write fakeFile

{'fraction_non_alphanumeric': 0.1330147351652728, 'fraction_numerical': 0.009557945041816009, 'mean_word_length': 2.9621451104100944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '62254', 'n_tokens_mistral': 862, 'n_tokens_neox': 834, 'n_words': 198}