Browse Source

fix test server

v1.x
TJ Holowaychuk 12 years ago
parent
commit
930d5be4d0
  1. 6
      package.json
  2. 15
      test/server.js
  3. 2
      test/views/layout.jade
  4. 36
      test/views/tests.jade

6
package.json

@ -9,11 +9,11 @@
"test": "make test"
}
, "devDependencies": {
"express": ">= 2.3.7 && < 3.0.0"
, "jade": "0.11.0"
"express": "3.0"
, "jade": "0.28.1"
, "mocha": "*"
, "should": "*"
}
, "engines": { "node": ">= 0.4.0" }
, "engines": { "node": ">= 0.6.0" }
, "main": "./lib/canvas.js"
}

15
test/server.js

@ -6,12 +6,10 @@
var express = require('express')
, Canvas = require('../lib/canvas')
, Image = Canvas.Image
, jade = require('jade')
, app = express.createServer();
, app = express();
// Config
app.register('.jade', jade);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
@ -22,7 +20,7 @@ app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({ showStack: true }));
app.use(express.errorHandler());
// Routes
@ -36,7 +34,7 @@ app.post('/render', function(req, res, next){
req.body.fn = req.body.fn
.replace("'state.png'", "'" + __dirname + "/public/state.png'")
.replace("'face.jpeg'", "'" + __dirname + "/public/face.jpeg'");
// Do not try this at home :)
var fn = eval('(' + req.body.fn + ')')
, width = req.body.width
@ -52,10 +50,11 @@ app.post('/render', function(req, res, next){
});
}
2 == fn.length
2 == fn.length
? fn(ctx, done)
: fn(ctx), done();
});
app.listen(parseInt(process.argv[2] || '3000', 10));
console.log('Test server listening on port %d', app.address().port);
var port = parseInt(process.argv[2] || '4000', 10);
app.listen(port);
console.log('Test server listening on port %d', port);

2
test/views/layout.jade

@ -6,4 +6,4 @@ html
script(src='/tests.js')
script(src='/app.js')
body
#primary!= body
block content

36
test/views/tests.jade

@ -1,19 +1,23 @@
h1 node-canvas
p.msg
| The tests below assert visual and api integrity by running the
em exact
| same code utilizing the client canvas api, as well as node-canvas.
extend layout
p
| Click to
a#run(href='#') re-run
| the test suite or "r".
block content
h1 node-canvas
table#tests
thead
tr
th node-canvas
th target
th
tbody
p.msg
| The tests below assert visual and api integrity by running the
em &nbsp;exact&nbsp;
| same code utilizing the client canvas api, as well as node-canvas.
p
| Click to
a#run(href='#') &nbsp;re-run&nbsp;
| the test suite or "r".
table#tests
thead
tr
th node-canvas
th target
th
tbody

Loading…
Cancel
Save