-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathprocessor_test.coffee
More file actions
71 lines (58 loc) · 2.16 KB
/
Copy pathprocessor_test.coffee
File metadata and controls
71 lines (58 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Processor = require('../lib/processor')
describe "Processor", ->
processor = ''
version = ''
beforeEach ->
processor = new Processor
extension: 'jpg'
quality: 1
custom: []
version =
name: 'test'
size: '320x160'
it "should parse size", ->
size = processor.getSize(version.size)
size.width.should.eql '320'
size.height.should.eql '160'
describe 'process', ->
it "should crop image", (done)->
processor.crop 'test', './images/sample.jpg', version, (err, stdout, stderr)->
err?.should.be.false
(typeof stdout).should.eql 'string'
done()
it "should resize image", (done)->
processor.resize 'test', './images/sample.jpg', version, (err, stdout, stderr)->
err?.should.be.false
(typeof stdout).should.eql 'string'
done()
it "should copy image", (done)->
processor.copy 'test', './images/sample.jpg', version, (err, file)->
err?.should.be.false
file?.should.be.ok
done()
it "should handle error", (done)->
processor.crop 'test', './images/error.jpg', version, (err, stdout, stderr)->
err?.should.be.ok
err.message?.should.be.ok
done()
describe 'params', ->
beforeEach ->
processor.im =
params: ''
crop: (@params, callback)->
callback()
it "should take version config over global config", (done)->
processor.crop 'test', './images/sample.jpg', version, (err, stdout, stderr)->
processor.im.params.format.should.eql processor.config.extension
processor.im.params.quality.should.eql processor.config.quality
version.extension = 'png'
version.quality = '0.5'
processor.crop 'test', './images/sample.jpg', version, (err, stdout, stderr)->
processor.im.params.format.should.eql 'png'
processor.im.params.quality.should.eql '0.5'
done()
it "should be able to pass customArgs", (done)->
version.custom = [ '-auto-orient' ]
processor.crop 'test', './images/sample.jpg', version, (err, stdout, stderr)->
processor.im.params.customArgs.should.eql [ '-auto-orient' ]
done()