KaTeX/server.js
Emily Eisenberg 507a552ffd Add some basic testing using jasmine
Summary:
Make some tests that test the parser. So far, there are no DOM tests,
but maybe later.

Test Plan:
Run `make serve` and then visit `/test/test.html`. Make sure all the
tests pass.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D2987
2013-07-11 18:32:44 -07:00

55 lines
1.4 KiB
JavaScript

var path = require("path");
var browserify = require("browserify");
var express = require("express");
var jisonify = require("./jisonify");
var app = express();
app.use(express.logger());
app.get("/katex.js", function(req, res, next) {
var b = browserify();
b.add("./katex");
b.transform(jisonify);
var stream = b.bundle({standalone: "katex"});
var body = "";
stream.on("data", function(s) { body += s; });
stream.on("error", function(e) { next(e); });
stream.on("end", function() {
res.setHeader("Content-Type", "text/javascript");
res.send(body);
});
});
app.get("/test/katex-tests.js", function(req, res, next) {
var b = browserify();
b.add("./test/katex-tests");
b.transform(jisonify);
var stream = b.bundle({});
var body = "";
stream.on("data", function(s) { body += s; });
stream.on("error", function(e) { next(e); });
stream.on("end", function() {
res.setHeader("Content-Type", "text/javascript");
res.send(body);
});
});
app.use(express.static(path.join(__dirname, "static")));
app.use("/test", express.static(path.join(__dirname, "test")));
app.use(function(err, req, res, next) {
console.error(err.stack);
res.setHeader("Content-Type", "text/plain");
res.send(500, err.stack);
});
app.listen(7936);
console.log("Serving on http://0.0.0.0:7936/ ...");