UNPKG

1.36 kBtext/coffeescriptView Raw
1
2should = require('chai').should()
3rack = require '../.'
4express = require 'express.io'
5easyrequest = require 'request'
6fs = require 'fs'
7
8describe 'a snockets asset', ->
9 app = null
10 fixturesDir = "#{__dirname}/fixtures/snockets"
11
12 it 'should work', (done) ->
13 compiled = fs.readFileSync "#{fixturesDir}/app.js", 'utf8'
14 app = express().http()
15 app.use new rack.SnocketsAsset
16 filename: "#{fixturesDir}/app.coffee"
17 url: '/app.js'
18 app.listen 7076, ->
19 easyrequest 'http://localhost:7076/app.js', (error, response, body) ->
20 response.headers['content-type'].should.equal 'text/javascript'
21 body.should.equal compiled
22 done()
23
24 it 'should work compressed', (done) ->
25 compiled = fs.readFileSync "#{fixturesDir}/app.min.js", 'utf8'
26 app = express().http()
27 app.use new rack.SnocketsAsset
28 filename: "#{fixturesDir}/app.coffee"
29 url: '/app.js'
30 compress: true
31 app.listen 7076, ->
32 easyrequest 'http://localhost:7076/app.js', (error, response, body) ->
33 response.headers['content-type'].should.equal 'text/javascript'
34 body.should.equal compiled
35 done()
36
37 afterEach (done) -> process.nextTick ->
38 app.server.close done