<commit_before>chai            = require 'chai'
sinon           = require 'sinon'
sinonChai       = require 'sinon-chai'
should          = chai.should()
expect          = chai.expect
assert          = chai.assert
chai.use(sinonChai)

setImmediate    = setImmediate || process.nextTick

TemplateFile    = require '../src'
Resource        = require 'resource-file'
fs              = require 'graceful-fs'
require 'task-registry-template-engine-lodash'

fs.cwd = process.cwd
Resource.setFileSystem fs

describe 'TemplateFileTask', ->
  task = TemplateFile()

  describe 'executeSync', ->
    it 'should render a file contents via object', ->
      file = Resource './fixture/src.md', cwd:__dirname
      result = task.executeSync file
      expect(result).to.be.equal """
      # this is a pretty title

      你好 Riceball Riceball.
      """
      expect(file.contents).to.be.equal """
      ---
      title: this is a pretty title
      author: Riceball
      ---
      # this is a pretty title

      你好 Riceball Riceball.
      """<commit_msg>* fixed testing on windows<commit_after>chai            = require 'chai'
sinon           = require 'sinon'
sinonChai       = require 'sinon-chai'
should          = chai.should()
expect          = chai.expect
assert          = chai.assert
chai.use(sinonChai)

setImmediate    = setImmediate || process.nextTick

TemplateFile    = require '../src'
Resource        = require 'resource-file'
fs              = require 'graceful-fs'
require 'task-registry-template-engine-lodash'

fs.cwd = process.cwd
fs.path = require 'path.js'
Resource.setFileSystem fs

describe 'TemplateFileTask', ->
  task = TemplateFile()

  describe 'executeSync', ->
    it 'should render a file contents via object', ->
      file = Resource './fixture/src.md', cwd:__dirname
      result = task.executeSync file
      expect(result).to.be.equal """
      # this is a pretty title

      你好 Riceball Riceball.
      """
      expect(file.contents).to.be.equal """
      ---
      title: this is a pretty title
      author: Riceball
      ---
      # this is a pretty title

      你好 Riceball Riceball.
      """
{'fraction_non_alphanumeric': 0.11189468735307946, 'fraction_numerical': 0.0, 'mean_word_length': 2.2096530920060333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4702554', 'n_tokens_mistral': 642, 'n_tokens_neox': 631, 'n_words': 169}