Skip to content

Commit

Permalink
Move adapter tests to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobeat committed May 14, 2013
1 parent a92d5e2 commit d14a570
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 117 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"stylus": "*",
"nib": "*",
"csso": "*",
"handlebars": "*"
"handlebars": "*",
"require-tree": "*"
},
"repository": {
"type": "git",
Expand Down
26 changes: 26 additions & 0 deletions test/compilers/coffeescript.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
flour = require '../../flour'
should = require 'should'
fs = require 'fs'

flour.silent()

describe 'CoffeeScript compiler', ->

input_file = "#{dir.sources}/compile.coffee"
output_file = "#{dir.temp}/compile.js"

it 'should compile CoffeeScript and return the output', (done) ->
flour.compile input_file, (output) ->
output.should.include 'bacon = function'
done()

it 'should compile CoffeeScript to a file', (done) ->
flour.compile input_file, output_file, ->
readFile(output_file).should.include 'bacon = function'
done()

it 'should compile CoffeeScript to a file && return the output', (done) ->
flour.compile input_file, output_file, (res) ->
should.exist fs.existsSync output_file
res.should.include 'bacon = function'
done()
37 changes: 37 additions & 0 deletions test/compilers/less.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
flour = require '../../flour'
should = require 'should'

flour.silent()

describe 'LESS compiler', ->

input_file = "#{dir.sources}/compile.less"
output_file = "#{dir.temp}/compile.css"

it 'should compile LESS and return the output', (done) ->
flour.compile input_file, (output) ->
output.should.include '.one .two'
done()

it 'should compile LESS to a file', (done) ->
flour.compile input_file, output_file, ->
readFile(output_file).should.include '.one .two{color' # compressed by default
done()

it 'should compile LESS to a file && return the output', (done) ->
flour.compile input_file, output_file, (res) ->
readFile(output_file).should.include '.one .two'
res.should.include '.one .two'
done()

it 'should compile LESS with compression disabled', (done) ->
flour.compilers.less.compress = false
flour.compile input_file, (output) ->
output.should.include '.one .two {\n color: #abcdef;\n}'
done()

it 'should compile LESS with yui compression enabled', (done) ->
flour.compilers.less.yuicompress = true
flour.compile input_file, (output) ->
output.should.include '.one .two{color:#abcdef}'
done()
31 changes: 31 additions & 0 deletions test/compilers/stylus.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
flour = require '../../flour'
should = require 'should'

flour.silent()

describe 'Stylus compiler', ->

input_file = "#{dir.sources}/compile.styl"
output_file = "#{dir.temp}/compile.css"

it 'should compile Stylus and return the output', (done) ->
flour.compile input_file, (output) ->
output.should.include '.one .two'
done()

it 'should compile Stylus to a file', (done) ->
flour.compile input_file, output_file, ->
readFile(output_file).should.include '.one .two'
done()

it 'should compile Stylus to a file && return the output', (done) ->
flour.compile input_file, output_file, (res) ->
readFile(output_file).should.include '.one .two'
res.should.include '.one .two'
done()

it 'should compile Stylus with compression disabled', (done) ->
flour.compilers.styl.compress = false
flour.compile input_file, (output) ->
output.should.include '.one .two {\n color: #abcdef;\n}'
done()
123 changes: 7 additions & 116 deletions test/flour.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ path = require 'path'
flour = require '../flour'
File = require '../lib/file'

readFile = (file) -> fs.readFileSync(file).toString()
copyFile = (file, out) -> fs.writeFileSync out, readFile file
global.readFile = (file) -> fs.readFileSync(file).toString()
global.copyFile = (file, out) -> fs.writeFileSync out, readFile file

dir =
global.dir =
sources: 'test/sources'
temp: 'test/temp'

Expand All @@ -34,119 +34,6 @@ describe 'Flour', ->
it 'should expose a watch method', ->
flour.bundle.should.be.a('function')

describe 'CoffeeScript compiler', ->

input_file = "#{dir.sources}/compile.coffee"
output_file = "#{dir.temp}/compile.js"

it 'should compile CoffeeScript and return the output', (done) ->
flour.compile input_file, (output) ->
output.should.include 'bacon = function'
done()

it 'should compile CoffeeScript to a file', (done) ->
flour.compile input_file, output_file, ->
readFile(output_file).should.include 'bacon = function'
done()

it 'should compile CoffeeScript to a file && return the output', (done) ->
flour.compile input_file, output_file, (res) ->
should.exist fs.existsSync output_file
res.should.include 'bacon = function'
done()

describe 'LESS compiler', ->

input_file = "#{dir.sources}/compile.less"
output_file = "#{dir.temp}/compile.css"

it 'should compile LESS and return the output', (done) ->
flour.compile input_file, (output) ->
output.should.include '.one .two'
done()

it 'should compile LESS to a file', (done) ->
flour.compile input_file, output_file, ->
readFile(output_file).should.include '.one .two{color' # compressed by default
done()

it 'should compile LESS to a file && return the output', (done) ->
flour.compile input_file, output_file, (res) ->
readFile(output_file).should.include '.one .two'
res.should.include '.one .two'
done()

it 'should compile LESS with compression disabled', (done) ->
flour.compilers.less.compress = false
flour.compile input_file, (output) ->
output.should.include '.one .two {\n color: #abcdef;\n}'
done()

it 'should compile LESS with yui compression enabled', (done) ->
flour.compilers.less.yuicompress = true
flour.compile input_file, (output) ->
output.should.include '.one .two{color:#abcdef}'
done()


describe 'Stylus compiler', ->

input_file = "#{dir.sources}/compile.styl"
output_file = "#{dir.temp}/compile.css"

it 'should compile Stylus and return the output', (done) ->
flour.compile input_file, (output) ->
output.should.include '.one .two'
done()

it 'should compile Stylus to a file', (done) ->
flour.compile input_file, output_file, ->
readFile(output_file).should.include '.one .two'
done()

it 'should compile Stylus to a file && return the output', (done) ->
flour.compile input_file, output_file, (res) ->
readFile(output_file).should.include '.one .two'
res.should.include '.one .two'
done()

it 'should compile Stylus with compression disabled', (done) ->
flour.compilers.styl.compress = false
flour.compile input_file, (output) ->
output.should.include '.one .two {\n color: #abcdef;\n}'
done()


describe 'JS minifier', ->

input_file = "#{dir.sources}/minify.js"
output_file = "#{dir.temp}/minify.min.js"

it 'should minify javascript and return the output', (done) ->
flour.minify input_file, (output) ->
output.should.include 'function test(){return'
done()

it 'should minify javascript to a file', (done) ->
flour.minify input_file, output_file, ->
readFile(output_file).should.include 'function test(){return'
done()


describe 'CSS minifier', ->

input_file = "#{dir.sources}/minify.css"
output_file = "#{dir.temp}/minify.min.css"

it 'should minify css and return the output', (done) ->
flour.minify input_file, (output) ->
output.should.include 'body,p{color:red}'
done()

it 'should minify css to a file', (done) ->
flour.minify input_file, output_file, ->
readFile(output_file).should.include 'body,p{color:red}'
done()

describe 'Bundle', ->

Expand Down Expand Up @@ -353,3 +240,7 @@ describe 'File path handling', ->
should.exist fs.existsSync out
readFile(out).should.include 'bacon = function'
done()

requiretree = require 'require-tree'
requiretree('test/compilers')
requiretree('test/minifiers')
19 changes: 19 additions & 0 deletions test/minifiers/csso.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
flour = require '../../flour'
should = require 'should'

flour.silent()

describe 'CSS minifier', ->

input_file = "#{dir.sources}/minify.css"
output_file = "#{dir.temp}/minify.min.css"

it 'should minify css and return the output', (done) ->
flour.minify input_file, (output) ->
output.should.include 'body,p{color:red}'
done()

it 'should minify css to a file', (done) ->
flour.minify input_file, output_file, ->
readFile(output_file).should.include 'body,p{color:red}'
done()
19 changes: 19 additions & 0 deletions test/minifiers/uglify-js.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
flour = require '../../flour'
should = require 'should'

flour.silent()

describe 'JS minifier', ->

input_file = "#{dir.sources}/minify.js"
output_file = "#{dir.temp}/minify.min.js"

it 'should minify javascript and return the output', (done) ->
flour.minify input_file, (output) ->
output.should.include 'function test(){return'
done()

it 'should minify javascript to a file', (done) ->
flour.minify input_file, output_file, ->
readFile(output_file).should.include 'function test(){return'
done()

0 comments on commit d14a570

Please sign in to comment.