overleaf/services/filestore/test/unit/coffee/ImageOptimiserTests.coffee

39 lines
946 B
CoffeeScript
Raw Normal View History

2014-02-14 16:39:05 +00:00
assert = require("chai").assert
sinon = require('sinon')
chai = require('chai')
should = chai.should()
expect = chai.expect
modulePath = "../../../app/js/ImageOptimiser.js"
SandboxedModule = require('sandboxed-module')
describe "ImageOptimiser", ->
beforeEach ->
@child_process =
exec : sinon.stub()
2014-02-14 16:39:05 +00:00
@optimiser = SandboxedModule.require modulePath, requires:
'child_process': @child_process
2014-02-14 16:39:05 +00:00
"logger-sharelatex":
log:->
err:->
@sourcePath = "/this/path/here.eps"
@error = "Error"
describe "compressPng", ->
it "convert the file", (done)->
@child_process.exec.callsArgWith(2)
2014-02-14 16:39:05 +00:00
@optimiser.compressPng @sourcePath, (err)=>
args = @child_process.exec.args[0][0]
args.should.equal "optipng #{@sourcePath}"
2014-02-14 16:39:05 +00:00
done()
it "should return the errro the file", (done)->
@child_process.exec.callsArgWith(2, @error)
2014-02-14 16:39:05 +00:00
@optimiser.compressPng @sourcePath, (err)=>
err.should.equal @error
2014-02-14 16:39:05 +00:00
done()