
Summary: Move dom creation into katex.js so our tests can test non-dom things, and add some buildTree tests. Add some checks make utils.js work in node. Add support for jasmine-node, to allow for command line unit testing. Test Plan: - Make sure tests work, in both the browser and with `make test` - Make sure huxley screenshots didn't change Reviewers: alpert Reviewed By: alpert Differential Revision: http://phabricator.khanacademy.org/D13125
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
var fs = require("fs");
|
|
var path = require("path");
|
|
|
|
var browserify = require("browserify");
|
|
var express = require("express");
|
|
var less = require("less");
|
|
|
|
var app = express();
|
|
|
|
app.use(express.logger());
|
|
|
|
app.get("/katex.js", function(req, res, next) {
|
|
var b = browserify();
|
|
b.add("./katex");
|
|
|
|
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("/katex.css", function(req, res, next) {
|
|
fs.readFile("static/katex.less", {encoding: "utf8"}, function(err, data) {
|
|
if (err) {
|
|
next(err);
|
|
return;
|
|
}
|
|
less.render(data, function(err, css) {
|
|
if (err) {
|
|
next(err);
|
|
return;
|
|
}
|
|
res.setHeader("Content-Type", "text/css");
|
|
res.send(css);
|
|
});
|
|
});
|
|
});
|
|
|
|
app.get("/test/katex-spec.js", function(req, res, next) {
|
|
var b = browserify();
|
|
b.add("./test/katex-spec");
|
|
|
|
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(express.static(path.join(__dirname, "build")));
|
|
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/ ...");
|