1 |
|
2 | should = require('chai').should()
|
3 | rack = require '../.'
|
4 | express = require 'express.io'
|
5 | easyrequest = require 'request'
|
6 | fs = require 'fs'
|
7 |
|
8 | describe 'a stylus asset', ->
|
9 | app = null
|
10 | fixturesDir = "#{__dirname}/fixtures/stylus"
|
11 |
|
12 | it 'should work', (done) ->
|
13 | compiled = fs.readFileSync "#{fixturesDir}/simple.css", 'utf8'
|
14 | app = express().http()
|
15 | app.use new rack.StylusAsset
|
16 | filename: "#{fixturesDir}/simple.styl"
|
17 | url: '/style.css'
|
18 | app.listen 7076, ->
|
19 | easyrequest 'http://localhost:7076/style.css', (error, response, body) ->
|
20 | response.headers['content-type'].should.equal 'text/css'
|
21 | body.should.equal compiled
|
22 | done()
|
23 |
|
24 | it 'should work compressed', (done) ->
|
25 | compiled = fs.readFileSync "#{fixturesDir}/simple.min.css", 'utf8'
|
26 | app = express().http()
|
27 | app.use new rack.StylusAsset
|
28 | filename: "#{fixturesDir}/simple.styl"
|
29 | url: '/style.css'
|
30 | compress: true
|
31 | app.listen 7076, ->
|
32 | easyrequest 'http://localhost:7076/style.css', (error, response, body) ->
|
33 | response.headers['content-type'].should.equal 'text/css'
|
34 | body.should.equal compiled
|
35 | done()
|
36 |
|
37 | it 'should work with a rack', (done) ->
|
38 | app = express().http()
|
39 | app.use new rack.Rack [
|
40 | new rack.Asset
|
41 | url: '/background.png'
|
42 | contents: 'not a real png'
|
43 | new rack.StylusAsset
|
44 | filename: "#{__dirname}/fixtures/stylus/simple.styl"
|
45 | url: '/simple.css'
|
46 | new rack.StylusAsset
|
47 | filename: "#{__dirname}/fixtures/stylus/dependency.styl"
|
48 | url: '/dependency.css'
|
49 | compress: true
|
50 | ]
|
51 | app.listen 7076, ->
|
52 | easyrequest 'http://localhost:7076/dependency.css', (error, response, body) ->
|
53 | response.headers['content-type'].should.equal 'text/css'
|
54 |
|
55 | done()
|
56 |
|
57 | afterEach (done) -> process.nextTick ->
|
58 | app.server.close done
|