<commit_before>require './spec_helper'
Package = rewire '../lib/package'

describe 'Package Module', ->

  before ->
    global.templatePath = 'test_path'

    Package.__set__("fs", {
      copySync: -> "copy success"
      appendFileSync: -> "append success"
    })

  it 'should create a new instance', ->
    pack = new Package()
    create = sinon.spy(pack, 'create')
    copyTemp = sinon.spy(pack, 'copyTemplate')
    rename = sinon.spy(pack, 'renamePackage')
    fsp = sinon.spy(fs, 'appendFileSync')
    pack.create('myTemplate')

    copyTemp.should.have.been.calledWith 'myTemplate'
    rename.should.have.been.calledOnce
    fsp.should.have.been.calledWithExactly './.meteor/packages', 'myTemplate'

  it "should copy the package template folder to clients root folder", ->
    pack = new Package()
    copy = sinon.spy(fs, 'copySync')
    pack.copyTemplate('packageDeluxe')
    path = 'test_path/package'
    dest = './packages/packageDeluxe'

    copy.should.have.been.calledWith(path, dest)
    copy.should.have.returned 'copy success'

<commit_msg>update tests for existsSync<commit_after>require './spec_helper'
Package = rewire '../lib/package'

describe 'Package Module', ->

  before ->
    global.templatePath = 'test_path'

    Package.__set__("fs", {
      copySync: -> "copy success"
      existsSync: -> false
      appendFileSync: -> "append success"
    })

  it 'should create a new instance', ->
    pack = new Package()
    create = sinon.spy(pack, 'create')
    copyTemp = sinon.spy(pack, 'copyTemplate')
    rename = sinon.spy(pack, 'renamePackage')
    fsp = sinon.spy(fs, 'appendFileSync')
    pack.create('myTemplate')

    copyTemp.should.have.been.calledWith 'myTemplate'
    rename.should.have.been.calledOnce
    fsp.should.have.been.calledWithExactly './.meteor/packages', 'myTemplate'

  it "should copy the package template folder to clients root folder", ->
    pack = new Package()
    copy = sinon.spy(fs, 'copySync')
    pack.copyTemplate('packageDeluxe')
    path = 'test_path/package'
    dest = './packages/packageDeluxe'

    copy.should.have.been.calledWith(path, dest)
    copy.should.have.returned 'copy success'


{'fraction_non_alphanumeric': 0.13903002309468823, 'fraction_numerical': 0.0, 'mean_word_length': 3.3493975903614457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '4007492', 'n_tokens_mistral': 714, 'n_tokens_neox': 684, 'n_words': 151}