Skip to content

Commit

Permalink
Add mocha tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Sep 3, 2012
1 parent 876b667 commit b1a0817
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/middleware.coffee
@@ -0,0 +1,36 @@

fs = require 'fs'
middleware = require '../lib/middleware'
rimraf = require 'rimraf'
should = require 'should'

describe 'middleware', ->

it 'should compile a coffee file', (next) ->
rimraf "#{__dirname}/../sample/public", (err) ->
options =
src: "#{__dirname}/../sample/view"
dest: "#{__dirname}/../sample/public"
req =
url: 'http://localhost/test.js'
method: 'GET'
res = {}
middleware(options) req, res, () ->
fs.exists "#{__dirname}/../sample/public/test.js", (exists) ->
exists.should.be.ok
next()

it 'should honor the base directory', (next) ->
rimraf "#{__dirname}/../sample/public", (err) ->
options =
baseDir: "#{__dirname}/../sample"
src: './view'
dest: './public'
req =
url: 'http://localhost/test.js'
method: 'GET'
res = {}
middleware(options) req, res, () ->
fs.exists "#{__dirname}/../sample/public/test.js", (exists) ->
exists.should.be.ok
next()

0 comments on commit b1a0817

Please sign in to comment.