Skip to content

Tests: Add Themeroller tests #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
443 changes: 443 additions & 0 deletions test/fixtures/jquery-ui-1.12.1/themes/smoothness.css

Large diffs are not rendered by default.

446 changes: 446 additions & 0 deletions test/fixtures/jquery-ui-1.13.2/themes/smoothness.css

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions test/fixtures/vars/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"ffDefault": "Arial,Helvetica,sans-serif",
"fsDefault": "1em",
"fwDefault": "normal",
"cornerRadius": "3px",
"bgColorHeader": "e9e9e9",
"bgTextureHeader": "flat",
"borderColorHeader": "dddddd",
"fcHeader": "333333",
"iconColorHeader": "444444",
"bgColorContent": "ffffff",
"bgTextureContent": "flat",
"borderColorContent": "dddddd",
"fcContent": "333333",
"iconColorContent": "444444",
"bgColorDefault": "f6f6f6",
"bgTextureDefault": "flat",
"borderColorDefault": "c5c5c5",
"fcDefault": "454545",
"iconColorDefault": "777777",
"bgColorHover": "ededed",
"bgTextureHover": "flat",
"borderColorHover": "cccccc",
"fcHover": "2b2b2b",
"iconColorHover": "555555",
"bgColorActive": "007fff",
"bgTextureActive": "flat",
"borderColorActive": "003eff",
"fcActive": "ffffff",
"iconColorActive": "ffffff",
"bgColorHighlight": "fffa90",
"bgTextureHighlight": "flat",
"borderColorHighlight": "dad55e",
"fcHighlight": "777620",
"iconColorHighlight": "777620",
"bgColorError": "fddfdf",
"bgTextureError": "flat",
"borderColorError": "f1a899",
"fcError": "5f3f3f",
"iconColorError": "cc0000",
"bgColorOverlay": "aaaaaa",
"bgTextureOverlay": "flat",
"bgImgOpacityOverlay": "0",
"opacityOverlay": "30",
"bgColorShadow": "666666",
"bgTextureShadow": "flat",
"bgImgOpacityShadow": "0",
"opacityShadow": "30",
"thicknessShadow": "5px",
"offsetTopShadow": "0px",
"offsetLeftShadow": "0px",
"cornerRadiusShadow": "8px"
}
60 changes: 60 additions & 0 deletions test/fixtures/vars/smoothness.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"ffDefault": "Verdana,Arial,sans-serif",
"fwDefault": "normal",
"fsDefault": "1.1em",
"cornerRadius": "4px",
"bgColorHeader": "cccccc",
"bgTextureHeader": "highlight_soft",
"bgImgOpacityHeader": "75",
"borderColorHeader": "aaaaaa",
"fcHeader": "222222",
"iconColorHeader": "222222",
"bgColorContent": "ffffff",
"bgTextureContent": "flat",
"bgImgOpacityContent": "75",
"borderColorContent": "aaaaaa",
"fcContent": "222222",
"iconColorContent": "222222",
"bgColorDefault": "e6e6e6",
"bgTextureDefault": "glass",
"bgImgOpacityDefault": "75",
"borderColorDefault": "d3d3d3",
"fcDefault": "555555",
"iconColorDefault": "888888",
"bgColorHover": "dadada",
"bgTextureHover": "glass",
"bgImgOpacityHover": "75",
"borderColorHover": "999999",
"fcHover": "212121",
"iconColorHover": "454545",
"bgColorActive": "ffffff",
"bgTextureActive": "glass",
"bgImgOpacityActive": "65",
"borderColorActive": "aaaaaa",
"fcActive": "212121",
"iconColorActive": "454545",
"bgColorHighlight": "fbf9ee",
"bgTextureHighlight": "glass",
"bgImgOpacityHighlight": "55",
"borderColorHighlight": "fcefa1",
"fcHighlight": "363636",
"iconColorHighlight": "2e83ff",
"bgColorError": "fef1ec",
"bgTextureError": "glass",
"bgImgOpacityError": "95",
"borderColorError": "cd0a0a",
"fcError": "cd0a0a",
"iconColorError": "cd0a0a",
"bgColorOverlay": "aaaaaa",
"bgTextureOverlay": "flat",
"bgImgOpacityOverlay": "0",
"opacityOverlay": "30",
"bgColorShadow": "aaaaaa",
"bgTextureShadow": "flat",
"bgImgOpacityShadow": "0",
"opacityShadow": "30",
"thicknessShadow": "8px",
"offsetTopShadow": "-8px",
"offsetLeftShadow": "-8px",
"cornerRadiusShadow": "8px"
}
60 changes: 60 additions & 0 deletions test/fixtures/vars/ui-darkness.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"ffDefault": "Segoe UI,Arial,sans-serif",
"fwDefault": "bold",
"fsDefault": "1.1em",
"cornerRadius": "6px",
"bgColorHeader": "333333",
"bgTextureHeader": "gloss_wave",
"bgImgOpacityHeader": "25",
"borderColorHeader": "333333",
"fcHeader": "ffffff",
"iconColorHeader": "ffffff",
"bgColorContent": "000000",
"bgTextureContent": "inset_soft",
"bgImgOpacityContent": "25",
"borderColorContent": "666666",
"fcContent": "ffffff",
"iconColorContent": "cccccc",
"bgColorDefault": "555555",
"bgTextureDefault": "glass",
"bgImgOpacityDefault": "20",
"borderColorDefault": "666666",
"fcDefault": "eeeeee",
"iconColorDefault": "cccccc",
"bgColorHover": "0078a3",
"bgTextureHover": "glass",
"bgImgOpacityHover": "40",
"borderColorHover": "59b4d4",
"fcHover": "ffffff",
"iconColorHover": "ffffff",
"bgColorActive": "f58400",
"bgTextureActive": "inset_soft",
"bgImgOpacityActive": "30",
"borderColorActive": "ffaf0f",
"fcActive": "ffffff",
"iconColorActive": "222222",
"bgColorHighlight": "eeeeee",
"bgTextureHighlight": "highlight_soft",
"bgImgOpacityHighlight": "80",
"borderColorHighlight": "cccccc",
"fcHighlight": "2e7db2",
"iconColorHighlight": "4b8e0b",
"bgColorError": "ffc73d",
"bgTextureError": "glass",
"bgImgOpacityError": "40",
"borderColorError": "ffb73d",
"fcError": "111111",
"iconColorError": "a83300",
"bgColorOverlay": "5c5c5c",
"bgTextureOverlay": "flat",
"bgImgOpacityOverlay": "50",
"opacityOverlay": "80",
"bgColorShadow": "cccccc",
"bgTextureShadow": "flat",
"bgImgOpacityShadow": "30",
"opacityShadow": "60",
"thicknessShadow": "7px",
"offsetTopShadow": "-7px",
"offsetLeftShadow": "-7px",
"cornerRadiusShadow": "8px"
}
60 changes: 60 additions & 0 deletions test/fixtures/vars/ui-lightness.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"ffDefault": "Trebuchet MS,Tahoma,Verdana,Arial,sans-serif",
"fwDefault": "bold",
"fsDefault": "1.1em",
"cornerRadius": "4px",
"bgColorHeader": "f6a828",
"bgTextureHeader": "gloss_wave",
"bgImgOpacityHeader": "35",
"borderColorHeader": "e78f08",
"fcHeader": "ffffff",
"iconColorHeader": "ffffff",
"bgColorContent": "eeeeee",
"bgTextureContent": "highlight_soft",
"bgImgOpacityContent": "100",
"borderColorContent": "dddddd",
"fcContent": "333333",
"iconColorContent": "222222",
"bgColorDefault": "f6f6f6",
"bgTextureDefault": "glass",
"bgImgOpacityDefault": "100",
"borderColorDefault": "cccccc",
"fcDefault": "1c94c4",
"iconColorDefault": "ef8c08",
"bgColorHover": "fdf5ce",
"bgTextureHover": "glass",
"bgImgOpacityHover": "100",
"borderColorHover": "fbcb09",
"fcHover": "c77405",
"iconColorHover": "ef8c08",
"bgColorActive": "ffffff",
"bgTextureActive": "glass",
"bgImgOpacityActive": "65",
"borderColorActive": "fbd850",
"fcActive": "eb8f00",
"iconColorActive": "ef8c08",
"bgColorHighlight": "ffe45c",
"bgTextureHighlight": "highlight_soft",
"bgImgOpacityHighlight": "75",
"borderColorHighlight": "fed22f",
"fcHighlight": "363636",
"iconColorHighlight": "228ef1",
"bgColorError": "b81900",
"bgTextureError": "diagonals_thick",
"bgImgOpacityError": "18",
"borderColorError": "cd0a0a",
"fcError": "ffffff",
"iconColorError": "ffd27a",
"bgColorOverlay": "666666",
"bgTextureOverlay": "diagonals_thick",
"bgImgOpacityOverlay": "20",
"opacityOverlay": "50",
"bgColorShadow": "000000",
"bgTextureShadow": "flat",
"bgImgOpacityShadow": "10",
"opacityShadow": "20",
"thicknessShadow": "5px",
"offsetTopShadow": "-5px",
"offsetLeftShadow": "-5px",
"cornerRadiusShadow": "5px"
}
2 changes: 1 addition & 1 deletion test/themeroller-themegallery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const fs = require( "fs" );
const fs = require( "node:fs" );
const zParams = require( "../lib/zparams" );
const { themeGalleryData } = require( "../lib/themeroller-themegallery" );

Expand Down
51 changes: 50 additions & 1 deletion test/themeroller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var fs = require( "fs" ),
var fs = require( "node:fs/promises" ),
ThemeRoller = require( "../lib/themeroller" );

module.exports = {
Expand Down Expand Up @@ -38,3 +38,52 @@ module.exports = {
}
}
};

const themeRollerTests = module.exports[ "test: ThemeRoller" ] = {};

( function() {
function dropThemeUrl( cssSource ) {
return cssSource.replace( /\n\s*\* To view and modify this theme, visit http:\/\/jqueryui\.com\/themeroller\/[^\n]+\n/, "\n" );
}

[ "1.12.1", "1.13.2" ].forEach( ( jQueryUiVersion ) => {
let theme;

themeRollerTests[ `with jQuery UI ${ jQueryUiVersion }` ] = {
async setUp( callback ) {
const varsString = await fs.readFile( `${ __dirname }/fixtures/vars/smoothness.json`, "utf-8" );
const vars = JSON.parse( varsString );

theme = new ThemeRoller( { vars, version: jQueryUiVersion } );
callback();
},

async [ "should instantiate" ]( test ) {
test.ok( theme instanceof ThemeRoller );
test.done();
},

async [ "should generate the theme CSS" ]( test ) {
const smoothnessCssFixture = await fs.readFile( `${ __dirname }/fixtures/jquery-ui-${ jQueryUiVersion }/themes/smoothness.css`, "utf-8" );

test.equal(
dropThemeUrl( theme.css() ),
dropThemeUrl( smoothnessCssFixture )
);
test.done();
},

async [ "should generate images" ]( test ) {
theme.generateImages( function( error, images ) {
try {
test.strictEqual( error, null );
test.ok( images && typeof images === "object" );
} finally {
test.done();
}
} );
}
};
} );

} )();