1 | path = require 'path'
|
2 | assert = require 'assert'
|
3 | express = require 'express'
|
4 | req = require 'supertest'
|
5 | browserify = require 'browserify'
|
6 | middleware = require '../index'
|
7 |
|
8 | fixture = (name) ->
|
9 | path.join(__dirname, 'fixtures', name)
|
10 |
|
11 | assertWorks = (app, done) ->
|
12 | req(app)
|
13 | .get('/bundle.js')
|
14 | .expect(200)
|
15 | .expect('Content-type', 'application/javascript')
|
16 | .end (err, res) ->
|
17 | return done(err) if err
|
18 | assert.ok /sourceMappingURL/.exec(res.text)
|
19 | assert.ok /module.exports = 'dep'/.exec(res.text)
|
20 | done()
|
21 |
|
22 | describe 'connect-browserify', ->
|
23 |
|
24 | it 'works (configured with module id)', (done) ->
|
25 | app = express()
|
26 | app.use '/bundle.js', middleware(fixture('main.js'), debug: true)
|
27 | assertWorks(app, done)
|
28 |
|
29 | it 'works (configured with options object)', (done) ->
|
30 | app = express()
|
31 | app.use '/bundle.js', middleware(entry: fixture('main.js'), debug: true)
|
32 | assertWorks(app, done)
|
33 |
|
34 | it 'works (configured with browserify instance)', (done) ->
|
35 | app = express()
|
36 | app.use '/bundle.js', middleware(browserify(fixture('main.js')), debug: true)
|
37 | assertWorks(app, done)
|