Merge pull request #11998 from atom/as-fix-janky-specs

Don't test CSON.readFileSync behavior twice (here and in atom/season)
This commit is contained in:
Antonio Scandurra 2016-06-18 00:17:19 +02:00 committed by GitHub
commit 5391907c49

View File

@ -4,7 +4,6 @@ Babel = require 'babel-core'
CoffeeScript = require 'coffee-script'
{TypeScriptSimple} = require 'typescript-simple'
CSON = require 'season'
CSONParser = require 'season/node_modules/cson-parser'
CompileCache = require '../src/compile-cache'
describe 'CompileCache', ->
@ -20,7 +19,6 @@ describe 'CompileCache', ->
spyOn(Babel, 'transform').andReturn {code: 'the-babel-code'}
spyOn(CoffeeScript, 'compile').andReturn {js: 'the-coffee-code', v3SourceMap: "{}"}
spyOn(TypeScriptSimple::, 'compile').andReturn 'the-typescript-code'
spyOn(CSONParser, 'parse').andReturn {the: 'cson-data'}
afterEach ->
CSON.setCacheDir(CompileCache.getCacheDirectory())
@ -64,11 +62,18 @@ describe 'CompileCache', ->
describe 'when the given file is CSON', ->
it 'compiles the file to JSON and caches it', ->
CompileCache.addPathToCache(path.join(fixtures, 'cson.cson'), atomHome)
expect(CSONParser.parse.callCount).toBe 1
spyOn(CSON, 'setCacheDir').andCallThrough()
spyOn(CSON, 'readFileSync').andCallThrough()
CompileCache.addPathToCache(path.join(fixtures, 'cson.cson'), atomHome)
expect(CSONParser.parse.callCount).toBe 1
expect(CSON.readFileSync).toHaveBeenCalledWith(path.join(fixtures, 'cson.cson'))
expect(CSON.setCacheDir).toHaveBeenCalledWith(path.join(atomHome, '/compile-cache'))
CSON.readFileSync.reset()
CSON.setCacheDir.reset()
CompileCache.addPathToCache(path.join(fixtures, 'cson.cson'), atomHome)
expect(CSON.readFileSync).toHaveBeenCalledWith(path.join(fixtures, 'cson.cson'))
expect(CSON.setCacheDir).not.toHaveBeenCalled()
describe 'overriding Error.prepareStackTrace', ->
it 'removes the override on the next tick, and always assigns the raw stack', ->