1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #1915 from kazuhitoyokoi/dev-addtestcases4themejs

Update test cases in theme_spec.js
This commit is contained in:
Nick O'Leary 2018-10-15 02:46:09 -07:00 committed by GitHub
commit c13e79e9c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,46 +26,52 @@ var NR_TEST_UTILS = require("nr-test-utils");
var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme"); var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme");
describe("api/editor/theme", function() { describe("api/editor/theme", function () {
beforeEach(function() { beforeEach(function () {
sinon.stub(fs,"statSync",function() { return true; }); sinon.stub(fs, "statSync", function () { return true; });
}); });
afterEach(function() { afterEach(function () {
theme.init({settings:{}}); theme.init({settings: {}});
fs.statSync.restore(); fs.statSync.restore();
}); });
it("applies the default theme", function() { it("applies the default theme", function () {
var result = theme.init({}); var result = theme.init({});
should.not.exist(result); should.not.exist(result);
var context = theme.context(); var context = theme.context();
context.should.have.a.property("page"); context.should.have.a.property("page");
context.page.should.have.a.property("title","Node-RED"); context.page.should.have.a.property("title", "Node-RED");
context.page.should.have.a.property("favicon","favicon.ico"); context.page.should.have.a.property("favicon", "favicon.ico");
context.page.should.have.a.property("tabicon", "red/images/node-red-icon-black.svg");
context.should.have.a.property("header"); context.should.have.a.property("header");
context.header.should.have.a.property("title","Node-RED"); context.header.should.have.a.property("title", "Node-RED");
context.header.should.have.a.property("image","red/images/node-red.png"); context.header.should.have.a.property("image", "red/images/node-red.png");
context.should.have.a.property("asset");
context.asset.should.have.a.property("red", "red/red.min.js");
context.asset.should.have.a.property("main", "red/main.min.js");
should.not.exist(theme.settings()); should.not.exist(theme.settings());
}); });
it("picks up custom theme", function() { it("picks up custom theme", function () {
theme.init({ theme.init({
editorTheme: { editorTheme: {
page: { page: {
title: "Test Page Title", title: "Test Page Title",
favicon: "/absolute/path/to/theme/icon", favicon: "/absolute/path/to/theme/favicon",
tabicon: "/absolute/path/to/theme/tabicon",
css: "/absolute/path/to/custom/css/file.css", css: "/absolute/path/to/custom/css/file.css",
scripts: "/absolute/path/to/script.js" scripts: "/absolute/path/to/script.js"
}, },
header: { header: {
title: "Test Header Title", title: "Test Header Title",
url: "http://nodered.org",
image: "/absolute/path/to/header/image" // or null to remove image image: "/absolute/path/to/header/image" // or null to remove image
}, },
deployButton: { deployButton: {
type:"simple", type: "simple",
label:"Save", label: "Save",
icon: "/absolute/path/to/deploy/button/image" // or null to remove image icon: "/absolute/path/to/deploy/button/image" // or null to remove image
}, },
@ -83,6 +89,16 @@ describe("api/editor/theme", function() {
login: { login: {
image: "/absolute/path/to/login/page/big/image" // a 256x256 image image: "/absolute/path/to/login/page/big/image" // a 256x256 image
},
palette: {
editable: true,
catalogues: ['https://catalogue.nodered.org/catalogue.json'],
theme: [{ category: ".*", type: ".*", color: "#f0f" }]
},
projects: {
enabled: false
} }
} }
}); });
@ -91,22 +107,40 @@ describe("api/editor/theme", function() {
var context = theme.context(); var context = theme.context();
context.should.have.a.property("page"); context.should.have.a.property("page");
context.page.should.have.a.property("title","Test Page Title"); context.page.should.have.a.property("title", "Test Page Title");
context.page.should.have.a.property("favicon", "theme/favicon/favicon");
context.page.should.have.a.property("tabicon", "theme/tabicon/tabicon");
context.should.have.a.property("header"); context.should.have.a.property("header");
context.header.should.have.a.property("title","Test Header Title"); context.header.should.have.a.property("title", "Test Header Title");
context.header.should.have.a.property("url", "http://nodered.org");
context.header.should.have.a.property("image", "theme/header/image");
context.page.should.have.a.property("css"); context.page.should.have.a.property("css");
context.page.css.should.have.lengthOf(1); context.page.css.should.have.lengthOf(1);
context.page.css[0].should.eql('theme/css/file.css'); context.page.css[0].should.eql('theme/css/file.css');
context.page.should.have.a.property("scripts"); context.page.should.have.a.property("scripts");
context.page.scripts.should.have.lengthOf(1); context.page.scripts.should.have.lengthOf(1);
context.page.scripts[0].should.eql('theme/scripts/script.js'); context.page.scripts[0].should.eql('theme/scripts/script.js');
context.should.have.a.property("login");
context.login.should.have.a.property("image", "theme/login/image");
var settings = theme.settings(); var settings = theme.settings();
settings.should.have.a.property("deployButton"); settings.should.have.a.property("deployButton");
settings.deployButton.should.have.a.property("type", "simple");
settings.deployButton.should.have.a.property("label", "Save");
settings.deployButton.should.have.a.property("icon", "theme/deploy/image");
settings.should.have.a.property("userMenu"); settings.should.have.a.property("userMenu");
settings.userMenu.should.be.eql(false);
settings.should.have.a.property("menu"); settings.should.have.a.property("menu");
settings.menu.should.have.a.property("menu-item-import-library", false);
settings.menu.should.have.a.property("menu-item-export-library", false);
settings.menu.should.have.a.property("menu-item-keyboard-shortcuts", false);
settings.menu.should.have.a.property("menu-item-help", { label: "Alternative Help Link Text", url: "http://example.com" });
settings.should.have.a.property("palette");
settings.palette.should.have.a.property("editable", true);
settings.palette.should.have.a.property("catalogues", ['https://catalogue.nodered.org/catalogue.json']);
settings.palette.should.have.a.property("theme", [{ category: ".*", type: ".*", color: "#f0f" }]);
settings.should.have.a.property("projects");
settings.projects.should.have.a.property("enabled", false);
}); });
}); });