@@ -11,6 +11,7 @@ describe 'preprocessor', ->
1111 mockFs = mocks .fs .create
1212 some :
1313 ' a.js' : mocks .fs .file 0 , ' content'
14+ ' b.js' : mocks .fs .file 0 , ' content'
1415 ' a.txt' : mocks .fs .file 0 , ' some-text'
1516 ' photo.png' : mocks .fs .file 0 , ' binary'
1617
@@ -96,6 +97,28 @@ describe 'preprocessor', ->
9697 expect (file .sha ).not .to .equal previousSHA
9798 done ()
9899
100+ it ' should compute SHA from content returned by a processor' , (done ) ->
101+ fakePreprocessor = sinon .spy (content, file, done) ->
102+ done null , content + ' -processed'
103+
104+ injector = new di.Injector [{
105+ ' preprocessor:fake' : [' factory' , -> fakePreprocessor]
106+ }]
107+
108+ pp = m .createPreprocessor {' **/a.js' : [' fake' ]}, null , injector
109+
110+ fileProcess = {originalPath : ' /some/a.js' , path : ' path' }
111+ fileSkip = {originalPath : ' /some/b.js' , path : ' path' }
112+
113+ pp fileProcess, ->
114+ pp fileSkip, ->
115+ expect (fileProcess .sha ).to .exist
116+ expect (fileProcess .sha .length ).to .equal 40
117+ expect (fileSkip .sha ).to .exist
118+ expect (fileSkip .sha .length ).to .equal 40
119+ expect (fileProcess .sha ).not .to .equal fileSkip .sha
120+ done ()
121+
99122
100123 it ' should return error if any preprocessor fails' , (done ) ->
101124 failingPreprocessor = sinon .spy (content, file, done) ->
0 commit comments