Browse Source

fix test server

v1.x
TJ Holowaychuk 12 years ago
parent
commit
96461fc636
  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" "test": "make test"
} }
, "devDependencies": { , "devDependencies": {
"express": ">= 2.3.7 && < 3.0.0" "express": "3.0"
, "jade": "0.11.0" , "jade": "0.28.1"
, "mocha": "*" , "mocha": "*"
, "should": "*" , "should": "*"
} }
, "engines": { "node": ">= 0.4.0" } , "engines": { "node": ">= 0.6.0" }
, "main": "./lib/canvas.js" , "main": "./lib/canvas.js"
} }

15
test/server.js

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

36
test/views/tests.jade

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