1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 01:50:28 +00:00

Added wikitest command

And fixed up the tests so that they work properly
This commit is contained in:
Jeremy Ruston 2012-05-02 17:28:03 +01:00
parent 067ed1b22c
commit 96a1c7650b
10 changed files with 82 additions and 9 deletions

View File

@ -0,0 +1,73 @@
/*\
title: $:/core/commands/wikitest.js
type: application/javascript
module-type: command
wikitest command
\*/
(function(){
/*jslint node: true, browser: true */
"use strict";
exports.info = {
name: "wikitest",
synchronous: false
};
var Command = function(params,commander) {
this.params = params;
this.commander = commander;
};
Command.prototype.execute = function() {
if(this.params.length <1) {
return "Missing parameters";
}
var fs = require("fs"),
path = require("path"),
testdirectory = this.params[0],
saveResults = this.params[1] === "save",
files = fs.readdirSync(testdirectory),
titles = [],
f,t,extname,basename;
for(f=0; f<files.length; f++) {
extname = path.extname(files[f]);
if(extname === ".tid") {
var tiddlers = this.commander.wiki.deserializeTiddlers(extname,fs.readFileSync(path.resolve(testdirectory,files[f]),"utf8"));
if(tiddlers.length > 1) {
throw "Cannot use .JSON files";
}
this.commander.wiki.addTiddler(new $tw.Tiddler(tiddlers[0]));
titles.push(tiddlers[0].title);
}
}
for(t=0; t<titles.length; t++) {
var htmlFilename = path.resolve(testdirectory,titles[t] + ".html"),
plainFilename = path.resolve(testdirectory,titles[t] + ".txt"),
htmlTarget = fs.readFileSync(htmlFilename,"utf8"),
plainTarget = fs.readFileSync(plainFilename,"utf8"),
tiddler = this.commander.wiki.getTiddler(titles[t]),
htmlRender = this.commander.wiki.renderTiddler("text/html",titles[t]),
plainRender = this.commander.wiki.renderTiddler("text/plain",titles[t]);
if(saveResults) {
// Save results
fs.writeFileSync(htmlFilename,htmlRender,"utf8");
fs.writeFileSync(plainFilename,plainRender,"utf8");
} else {
// Report results
if(htmlTarget !== htmlRender) {
this.commander.streams.output.write("Tiddler " + titles[t] + " html error\nTarget: " + htmlTarget + "\nFound: " + htmlRender +"\n");
}
if(plainTarget !== plainRender) {
this.commander.streams.output.write("Tiddler " + titles[t] + " plain text error\nTarget: " + plainTarget + "\nFound: " + plainRender + "\n");
}
}
}
return null; // No error
};
exports.Command = Command;
})();

View File

@ -1 +1 @@
<div data-tiddler-target='EighthTiddler' data-tiddler-template='EighthTiddler' class='tw-tiddler-frame'><div data-tiddler-target='SixthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>SixthTiddler<br>11 February 2011<br><a href='Jermolene' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing'>Jermolene</a><br></div><br><div data-tiddler-target='SixthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>SixthTiddler<br>11 February 2011<br><a href='Jermolene' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing'>Jermolene</a><br></div><br><div data-tiddler-target='EighthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>EighthTiddler<br><br><br></div><br><div data-tiddler-target='FirstTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>FirstTiddler<br><br><br></div><br></div>
<div data-tiddler-target='SixthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>SixthTiddler<br>11 February 2011<br><a href='Jermolene' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing'>Jermolene</a><br></div><br><div data-tiddler-target='SixthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>SixthTiddler<br>11 February 2011<br><a href='Jermolene' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing'>Jermolene</a><br></div><br><div data-tiddler-target='EighthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>EighthTiddler<br><br><br></div><br><div data-tiddler-target='FirstTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>FirstTiddler<br><br><br></div><br>

View File

@ -1 +1 @@
<div data-tiddler-target='Fifth Tiddler' data-tiddler-template='Fifth Tiddler' class='tw-tiddler-frame'><table class='table'><caption align='top'>A caption above the table</caption><thead><tr class='evenRow'><td align='center'>Left</td><td align='center'>Middle</td><td align='center'>Right</td></tr></thead><tbody><tr class='oddRow'><td>North West</td><td>North</td><td>North East</td></tr><tr class='evenRow'><td>West</td><td>Here</td><td>East</td></tr><tr class='oddRow'><td>South West</td><td>South</td><td>South East</td></tr></tbody></table></div>
<table class='table'><caption align='top'>A caption above the table</caption><thead><tr class='evenRow'><td align='center'>Left</td><td align='center'>Middle</td><td align='center'>Right</td></tr></thead><tbody><tr class='oddRow'><td>North West</td><td>North</td><td>North East</td></tr><tr class='evenRow'><td>West</td><td>Here</td><td>East</td></tr><tr class='oddRow'><td>South West</td><td>South</td><td>South East</td></tr></tbody></table>

View File

@ -1 +1 @@
<div data-tiddler-target='FirstTiddler' data-tiddler-template='FirstTiddler' class='tw-tiddler-frame'>This is the <strong>text</strong> of the first tiddler, with a <span style='font-size:8em;color:red;'>link</span> to the <a href='SecondTiddler' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-resolves'>SecondTiddler</a>, too. And a link to <a href='http://tiddlywiki.com/' class='tw-tiddlylink tw-tiddlylink-external'>http://tiddlywiki.com/</a>.<br></div>
This is the <strong>text</strong> of the first tiddler, with a <span style='font-size:8em;color:red;'>link</span> to the <a href='SecondTiddler' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-resolves'>SecondTiddler</a>, too. And a link to <a href='http://tiddlywiki.com/' class='tw-tiddlylink tw-tiddlylink-external'>http://tiddlywiki.com/</a>.<br>

View File

@ -1 +1 @@
<div data-tiddler-target='Fourth Tiddler' data-tiddler-template='Fourth Tiddler' class='tw-tiddler-frame'>A missing image <img src='Something.jpg'> and a $1 couple of &#xc7; &#199; &quot;HTML Entity&quot;</div>
A missing image <img src='Something.jpg'> and a $1 couple of &#xc7; &#199; &quot;HTML Entity&quot;

View File

@ -1 +1 @@
<div data-tiddler-target='SecondTiddler' data-tiddler-template='SecondTiddler' class='tw-tiddler-frame'><h2>Heading</h2>This is the second tiddler. It has a list:<br><ul><li> Item one</li><li> Item two</li><li> Item three</li></ul>And a macro invocation 5.0.0 and a <span class='myClass'>custom class</span><br></div>
<h2>Heading</h2>This is the second tiddler. It has a list:<br><ul><li> Item one</li><li> Item two</li><li> Item three</li></ul>And a macro invocation 5.0.0.a2 and a <span class='myClass'>custom class</span><br>

View File

@ -1 +1 @@
HeadingThis is the second tiddler. It has a list: Item one Item two Item threeAnd a macro invocation 5.0.0 and a custom class
HeadingThis is the second tiddler. It has a list: Item one Item two Item threeAnd a macro invocation 5.0.0.a2 and a custom class

View File

@ -1 +1 @@
<div data-tiddler-target='SeventhTiddler' data-tiddler-template='SeventhTiddler' class='tw-tiddler-frame'>4<br><br>SeventhTiddler<br><br>window<br></div>
4<br><br>SeventhTiddler<br><br>window<br>

View File

@ -1 +1 @@
<div data-tiddler-target='SixthTiddler' data-tiddler-template='SixthTiddler' class='tw-tiddler-frame'>SixthTiddler<br>11 February 2011<br><a href='Jermolene' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing'>Jermolene</a><br></div>
SixthTiddler<br>11 February 2011<br><a href='Jermolene' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing'>Jermolene</a><br>

View File

@ -1 +1 @@
<div data-tiddler-target='ThirdTiddler' data-tiddler-template='ThirdTiddler' class='tw-tiddler-frame'>An explicit link <a href='Fourth%20Tiddler' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-resolves'>Fourth Tiddler</a> and <a href='Fourth%20Tiddler' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-resolves'>a pretty link</a> and a transclusion <div data-tiddler-target='Fourth Tiddler' data-tiddler-template='Fourth Tiddler' class='tw-tiddler-frame'>A missing image <img src='Something.jpg'> and a Stringy couple of &#xc7; &#199; &quot;HTML Entity&quot;</div><br><br><img src='http://placehold.it/350x150'><br></div>
An explicit link <a href='Fourth%20Tiddler' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-resolves'>Fourth Tiddler</a> and <a href='Fourth%20Tiddler' class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-resolves'>a pretty link</a> and a transclusion <div data-tiddler-target='Fourth Tiddler' data-tiddler-template='Fourth Tiddler' class='tw-tiddler-frame'>A missing image <img src='Something.jpg'> and a Stringy couple of &#xc7; &#199; &quot;HTML Entity&quot;</div><br><br><img src='http://placehold.it/350x150'><br>