Skip to content

Commit

Permalink
Rely on CSON.readFileSync to test caching behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed Jun 17, 2016
1 parent 56a9894 commit bdce8d1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions spec/compile-cache-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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', ->
Expand All @@ -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())
Expand Down Expand Up @@ -64,11 +62,18 @@ describe 'CompileCache', ->

describe 'when the given file is CSON', ->
it 'compiles the file to JSON and caches it', ->
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(CSONParser.parse.callCount).toBe 1
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', ->
Expand Down

0 comments on commit bdce8d1

Please sign in to comment.