 path = require 'path'
 defaultConfig = require './default-config'
 grammarTest = require 'atom-grammar-test'
+temp = require('temp');
 
 LB = 'language-babel'
 # we use atom setPaths in this spec. setPaths checks if directories exist


    if not process.platform.match /^win/
      it 'returns paths for a named sourcefile with default config', ->
        atom.project.setPaths([PU+'/Project1', PU+'/Project2'])

        ret = lb.getPaths(PU+'/Project1/source/dira/fauxfile.js',config)

        expect(ret.sourceFile).to.equal(PU+'/Project1/source/dira/fauxfile.js')
        expect(ret.sourceFileDir).to.equal(PU+'/Project1/source/dira')
        expect(ret.mapFile).to.equal(PU+'/Project1/source/dira/fauxfile.js.map')
        expect(ret.transpiledFile).to.equal(PU+'/Project1/source/dira/fauxfile.js')
        expect(ret.sourceRoot).to.equal(PU+'/Project1')
        expect(ret.projectPath).to.equal(PU+'/Project1')

      it 'returns paths config with target & source paths set', ->
        atom.project.setPaths([PU+'/Project1', PU+'/Project2'])
        config.babelSourcePath = '/source' # with dir prefix
        config.babelMapsPath ='mapspath' # and without
        config.babelTranspilePath = '/transpath'

        ret = lb.getPaths(PU+'/Project1/source/dira/fauxfile.js',config)

        expect(ret.sourceFile).to.equal(PU+'/Project1/source/dira/fauxfile.js')
        expect(ret.sourceFileDir).to.equal(PU+'/Project1/source/dira')
        expect(ret.mapFile).to.equal(PU+'/Project1/mapspath/dira/fauxfile.js.map')
        expect(ret.transpiledFile).to.equal(PU+'/Project1/transpath/dira/fauxfile.js')
        expect(ret.sourceRoot).to.equal(PU+'/Project1/source')
        expect(ret.projectPath).to.equal(PU+'/Project1')

      it 'returns correct paths with project in root directory', ->
        atom.project.setPaths(['/'])
        config.babelSourcePath = 'source'
        config.babelMapsPath ='mapspath'

# were no found, atom sets the directory to the full name.
# We need some prefix directory faux names for posix and windows to ensure
# we always get a project name we set

describe 'language-babel', ->
  lb = null
  config =  {}
  beforeEach ->
    temp.cleanup()
    waitsForPromise ->
      atom.packages.activatePackage(LB)
    config = JSON.parse JSON.stringify defaultConfig
