mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #323 from zobalogh/further-registry-tests
Adding test for registry cheerio
This commit is contained in:
commit
989f3459d5
@ -197,7 +197,7 @@ function loadTemplate(nodeInfo) {
|
|||||||
|
|
||||||
var content = fs.readFileSync(templateFilename,'utf8');
|
var content = fs.readFileSync(templateFilename,'utf8');
|
||||||
|
|
||||||
$ = cheerio.load(content);
|
var $ = cheerio.load(content);
|
||||||
var template = "";
|
var template = "";
|
||||||
var script = "";
|
var script = "";
|
||||||
$("*").each(function(i,el) {
|
$("*").each(function(i,el) {
|
||||||
|
@ -84,6 +84,7 @@ describe("getNodeFiles", function() {
|
|||||||
|
|
||||||
var tempDir = path.join(__dirname,".tmp/");
|
var tempDir = path.join(__dirname,".tmp/");
|
||||||
var fakeNodeJS = tempDir + "testNode.js"; // when exported, this fake node creates a file we can assert on
|
var fakeNodeJS = tempDir + "testNode.js"; // when exported, this fake node creates a file we can assert on
|
||||||
|
var fakeNodeHTML = tempDir + "testNode.html"; // we assume it's going to be loaded by cheerio
|
||||||
|
|
||||||
var nodeInjectedFileName = "testInjected";
|
var nodeInjectedFileName = "testInjected";
|
||||||
var nodeInjectedFilePath = path.join(tempDir, nodeInjectedFileName);
|
var nodeInjectedFilePath = path.join(tempDir, nodeInjectedFileName);
|
||||||
@ -100,7 +101,26 @@ describe("getNodeFiles", function() {
|
|||||||
"module.exports = function(RED) {\n" +
|
"module.exports = function(RED) {\n" +
|
||||||
" fs.writeFileSync(tempFile, \"Test passes if this file has been written.\");\n" +
|
" fs.writeFileSync(tempFile, \"Test passes if this file has been written.\");\n" +
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
var htmlContents = "<script type=\"text/javascript\">\n" +
|
||||||
|
" RED.nodes.registerType('testFileInjector',{\n" +
|
||||||
|
" category: 'storage-input',\n" +
|
||||||
|
" inputs:0,\n" +
|
||||||
|
" outputs:1,\n" +
|
||||||
|
" icon: \"file.png\"\n" +
|
||||||
|
" });\n" +
|
||||||
|
"</script>\n" +
|
||||||
|
"<script type=\"text/x-red\" data-template-name=\"testFileInjector\">\n" +
|
||||||
|
" <div class=\"form-row\">\n" +
|
||||||
|
" <label for=\"node-input-name\"><i class=\"icon-tag\"></i> Name</label>\n" +
|
||||||
|
" <input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n" +
|
||||||
|
" </div>\n" +
|
||||||
|
"</script>\n" +
|
||||||
|
"<script type=\"text/x-red\" data-help-name=\"node-type\">\n" +
|
||||||
|
" <p>This node is pretty useless</p>\n" +
|
||||||
|
"</script>";
|
||||||
fs.writeFileSync(fakeNodeJS, fileContents);
|
fs.writeFileSync(fakeNodeJS, fileContents);
|
||||||
|
fs.writeFileSync(fakeNodeHTML, htmlContents);
|
||||||
fs.remove(tempNoNodesContainedDir,function(err) {
|
fs.remove(tempNoNodesContainedDir,function(err) {
|
||||||
fs.mkdirSync(tempNoNodesContainedDir);
|
fs.mkdirSync(tempNoNodesContainedDir);
|
||||||
done();
|
done();
|
||||||
@ -122,6 +142,12 @@ describe("getNodeFiles", function() {
|
|||||||
if(exists) {
|
if(exists) {
|
||||||
fs.unlinkSync(fakeNodeJS);
|
fs.unlinkSync(fakeNodeJS);
|
||||||
}
|
}
|
||||||
|
fs.remove(tempDir);
|
||||||
|
});
|
||||||
|
fs.exists(fakeNodeHTML, function(exists) {
|
||||||
|
if(exists) {
|
||||||
|
fs.unlinkSync(fakeNodeHTML);
|
||||||
|
}
|
||||||
fs.remove(tempDir, done);
|
fs.remove(tempDir, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -135,6 +161,21 @@ describe("getNodeFiles", function() {
|
|||||||
typeRegistry.init(settings);
|
typeRegistry.init(settings);
|
||||||
|
|
||||||
typeRegistry.load(tempNoNodesContainedDir).then(function(){
|
typeRegistry.load(tempNoNodesContainedDir).then(function(){
|
||||||
|
var testConfig = typeRegistry.getNodeConfigs();
|
||||||
|
|
||||||
|
try {
|
||||||
|
testConfig.should.equal( "<script type=\"text/x-red\" data-template-name=\"testFileInjector\">\n" +
|
||||||
|
" <div class=\"form-row\">\n" +
|
||||||
|
" <label for=\"node-input-name\"><i class=\"icon-tag\"></i> Name</label>\n" +
|
||||||
|
" <input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n" +
|
||||||
|
" </div>\n" +
|
||||||
|
"</script><script type=\"text/x-red\" data-help-name=\"node-type\">\n" +
|
||||||
|
" <p>This node is pretty useless</p>\n" +
|
||||||
|
"</script><script type=\"text/javascript\">RED.nodes.registerType(\"testFileInjector\",{category:\"storage-input\",inputs:0,outputs:1,icon:\"file.png\"});</script>");
|
||||||
|
} catch(err) {
|
||||||
|
done(err);
|
||||||
|
}
|
||||||
|
|
||||||
fs.exists(nodeInjectedFilePath, function(exists) {
|
fs.exists(nodeInjectedFilePath, function(exists) {
|
||||||
if(exists) {
|
if(exists) {
|
||||||
done();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user