Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick and dirty test interface for clientside
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!doctype html> | ||
<title>marked tests</title> | ||
<p>testing...</p> | ||
<script src="marked.js"></script> | ||
<script src="test.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var fs = require('fs'); | ||
|
||
var main = require('../') | ||
, load = main.load; | ||
|
||
var express = require('express') | ||
, app = express.createServer(); | ||
|
||
app.use(function(req, res, next) { | ||
var setHeader = res.setHeader; | ||
res.setHeader = function(name) { | ||
switch (name) { | ||
case 'Cache-Control': | ||
case 'Last-Modified': | ||
case 'ETag': | ||
return; | ||
} | ||
return setHeader.apply(res, arguments); | ||
}; | ||
next(); | ||
}); | ||
|
||
var dir = __dirname + '/../tests' | ||
, files = {}; | ||
|
||
app.get('/test.js', function(req, res, next) { | ||
var test = fs.readFileSync(__dirname + '/test.js', 'utf8') | ||
, files = load(); | ||
|
||
test = test.replace('__TESTS__', JSON.stringify(files)); | ||
test = test.replace('__MAIN__', main + ''); | ||
|
||
res.contentType('.js'); | ||
res.send(test); | ||
}); | ||
|
||
app.use(express.static(__dirname + '/../../lib')); | ||
app.use(express.static(__dirname)); | ||
|
||
app.listen(8080); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
;(function() { | ||
|
||
var files = __TESTS__; | ||
|
||
var BREAK_ON_ERROR = false; | ||
|
||
var print = function(text) { | ||
var args = Array.prototype.slice.call(arguments, 1) | ||
, i = 0; | ||
|
||
text = text.replace(/%\w/g, function() { | ||
return args[i++] || ''; | ||
}); | ||
|
||
if (window.console) window.console.log(text); | ||
document.body.innerHTML += '<pre>' + escape(text) + '</pre>'; | ||
}; | ||
|
||
var console = { log: print }; | ||
|
||
var pretty = function(text) { | ||
return text; | ||
}; | ||
|
||
var load = function() {}; | ||
|
||
Object.keys = Object.keys || function(obj) { | ||
var out = [] | ||
, key; | ||
|
||
for (key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
out.push(key); | ||
} | ||
} | ||
|
||
return out; | ||
}; | ||
|
||
String.prototype.trim = String.prototype.trim || function() { | ||
return this.replace(/^\s+|\s+$/g, ''); | ||
}; | ||
|
||
var escape = function(html, encode) { | ||
return html | ||
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, '''); | ||
}; | ||
|
||
var main = __MAIN__; | ||
|
||
main(); | ||
|
||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters