From adcb4022c7a6009a89f212e7ca77ca7835d0d84d Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 3 Jul 2022 01:50:47 -0700 Subject: [PATCH] test: spy on the actual compile function instead of spying on Babel --- spec/compile-cache-spec.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/compile-cache-spec.coffee b/spec/compile-cache-spec.coffee index f90b4267c..b00144a1a 100644 --- a/spec/compile-cache-spec.coffee +++ b/spec/compile-cache-spec.coffee @@ -1,6 +1,6 @@ path = require 'path' temp = require('temp').track() -Babel = require '@babel/core' +babelCompiler = require '../src/babel' CoffeeScript = require 'coffee-script' {TypeScriptSimple} = require 'typescript-simple' CSON = require 'season' @@ -16,7 +16,7 @@ describe 'CompileCache', -> CSON.setCacheDir(null) CompileCache.resetCacheStats() - spyOn(Babel, 'transformSync').andReturn {code: 'the-babel-code'} + spyOn(babelCompiler, 'compile') spyOn(CoffeeScript, 'compile').andReturn 'the-coffee-code' spyOn(TypeScriptSimple::, 'compile').andReturn 'the-typescript-code' @@ -36,11 +36,11 @@ describe 'CompileCache', -> it 'compiles the file with babel and caches it', -> CompileCache.addPathToCache(path.join(fixtures, 'babel', 'babel-comment.js'), atomHome) expect(CompileCache.getCacheStats()['.js']).toEqual {hits: 0, misses: 1} - expect(Babel.transformSync.callCount).toBe 1 + expect(babelCompiler.compile.callCount).toBe 1 CompileCache.addPathToCache(path.join(fixtures, 'babel', 'babel-comment.js'), atomHome) expect(CompileCache.getCacheStats()['.js']).toEqual {hits: 1, misses: 1} - expect(Babel.transformSync.callCount).toBe 1 + expect(babelCompiler.compile.callCount).toBe 1 describe 'when the given file is coffee-script', -> it 'compiles the file with coffee-script and caches it', ->