Skip to content

Commit 2b1f091

Browse files
committed
Tests: Add Themeroller tests
Ref jquery-archive/jquery-ui-themeroller#18
1 parent f542257 commit 2b1f091

File tree

8 files changed

+1173
-2
lines changed

8 files changed

+1173
-2
lines changed

test/fixtures/jquery-ui-1.12.1/themes/smoothness.css

+443
Large diffs are not rendered by default.

test/fixtures/jquery-ui-1.13.2/themes/smoothness.css

+446
Large diffs are not rendered by default.

test/fixtures/vars/base.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"ffDefault": "Arial,Helvetica,sans-serif",
3+
"fsDefault": "1em",
4+
"fwDefault": "normal",
5+
"cornerRadius": "3px",
6+
"bgColorHeader": "e9e9e9",
7+
"bgTextureHeader": "flat",
8+
"borderColorHeader": "dddddd",
9+
"fcHeader": "333333",
10+
"iconColorHeader": "444444",
11+
"bgColorContent": "ffffff",
12+
"bgTextureContent": "flat",
13+
"borderColorContent": "dddddd",
14+
"fcContent": "333333",
15+
"iconColorContent": "444444",
16+
"bgColorDefault": "f6f6f6",
17+
"bgTextureDefault": "flat",
18+
"borderColorDefault": "c5c5c5",
19+
"fcDefault": "454545",
20+
"iconColorDefault": "777777",
21+
"bgColorHover": "ededed",
22+
"bgTextureHover": "flat",
23+
"borderColorHover": "cccccc",
24+
"fcHover": "2b2b2b",
25+
"iconColorHover": "555555",
26+
"bgColorActive": "007fff",
27+
"bgTextureActive": "flat",
28+
"borderColorActive": "003eff",
29+
"fcActive": "ffffff",
30+
"iconColorActive": "ffffff",
31+
"bgColorHighlight": "fffa90",
32+
"bgTextureHighlight": "flat",
33+
"borderColorHighlight": "dad55e",
34+
"fcHighlight": "777620",
35+
"iconColorHighlight": "777620",
36+
"bgColorError": "fddfdf",
37+
"bgTextureError": "flat",
38+
"borderColorError": "f1a899",
39+
"fcError": "5f3f3f",
40+
"iconColorError": "cc0000",
41+
"bgColorOverlay": "aaaaaa",
42+
"bgTextureOverlay": "flat",
43+
"bgImgOpacityOverlay": "0",
44+
"opacityOverlay": "30",
45+
"bgColorShadow": "666666",
46+
"bgTextureShadow": "flat",
47+
"bgImgOpacityShadow": "0",
48+
"opacityShadow": "30",
49+
"thicknessShadow": "5px",
50+
"offsetTopShadow": "0px",
51+
"offsetLeftShadow": "0px",
52+
"cornerRadiusShadow": "8px"
53+
}

test/fixtures/vars/smoothness.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"ffDefault": "Verdana,Arial,sans-serif",
3+
"fwDefault": "normal",
4+
"fsDefault": "1.1em",
5+
"cornerRadius": "4px",
6+
"bgColorHeader": "cccccc",
7+
"bgTextureHeader": "highlight_soft",
8+
"bgImgOpacityHeader": "75",
9+
"borderColorHeader": "aaaaaa",
10+
"fcHeader": "222222",
11+
"iconColorHeader": "222222",
12+
"bgColorContent": "ffffff",
13+
"bgTextureContent": "flat",
14+
"bgImgOpacityContent": "75",
15+
"borderColorContent": "aaaaaa",
16+
"fcContent": "222222",
17+
"iconColorContent": "222222",
18+
"bgColorDefault": "e6e6e6",
19+
"bgTextureDefault": "glass",
20+
"bgImgOpacityDefault": "75",
21+
"borderColorDefault": "d3d3d3",
22+
"fcDefault": "555555",
23+
"iconColorDefault": "888888",
24+
"bgColorHover": "dadada",
25+
"bgTextureHover": "glass",
26+
"bgImgOpacityHover": "75",
27+
"borderColorHover": "999999",
28+
"fcHover": "212121",
29+
"iconColorHover": "454545",
30+
"bgColorActive": "ffffff",
31+
"bgTextureActive": "glass",
32+
"bgImgOpacityActive": "65",
33+
"borderColorActive": "aaaaaa",
34+
"fcActive": "212121",
35+
"iconColorActive": "454545",
36+
"bgColorHighlight": "fbf9ee",
37+
"bgTextureHighlight": "glass",
38+
"bgImgOpacityHighlight": "55",
39+
"borderColorHighlight": "fcefa1",
40+
"fcHighlight": "363636",
41+
"iconColorHighlight": "2e83ff",
42+
"bgColorError": "fef1ec",
43+
"bgTextureError": "glass",
44+
"bgImgOpacityError": "95",
45+
"borderColorError": "cd0a0a",
46+
"fcError": "cd0a0a",
47+
"iconColorError": "cd0a0a",
48+
"bgColorOverlay": "aaaaaa",
49+
"bgTextureOverlay": "flat",
50+
"bgImgOpacityOverlay": "0",
51+
"opacityOverlay": "30",
52+
"bgColorShadow": "aaaaaa",
53+
"bgTextureShadow": "flat",
54+
"bgImgOpacityShadow": "0",
55+
"opacityShadow": "30",
56+
"thicknessShadow": "8px",
57+
"offsetTopShadow": "-8px",
58+
"offsetLeftShadow": "-8px",
59+
"cornerRadiusShadow": "8px"
60+
}

test/fixtures/vars/ui-darkness.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"ffDefault": "Segoe UI,Arial,sans-serif",
3+
"fwDefault": "bold",
4+
"fsDefault": "1.1em",
5+
"cornerRadius": "6px",
6+
"bgColorHeader": "333333",
7+
"bgTextureHeader": "gloss_wave",
8+
"bgImgOpacityHeader": "25",
9+
"borderColorHeader": "333333",
10+
"fcHeader": "ffffff",
11+
"iconColorHeader": "ffffff",
12+
"bgColorContent": "000000",
13+
"bgTextureContent": "inset_soft",
14+
"bgImgOpacityContent": "25",
15+
"borderColorContent": "666666",
16+
"fcContent": "ffffff",
17+
"iconColorContent": "cccccc",
18+
"bgColorDefault": "555555",
19+
"bgTextureDefault": "glass",
20+
"bgImgOpacityDefault": "20",
21+
"borderColorDefault": "666666",
22+
"fcDefault": "eeeeee",
23+
"iconColorDefault": "cccccc",
24+
"bgColorHover": "0078a3",
25+
"bgTextureHover": "glass",
26+
"bgImgOpacityHover": "40",
27+
"borderColorHover": "59b4d4",
28+
"fcHover": "ffffff",
29+
"iconColorHover": "ffffff",
30+
"bgColorActive": "f58400",
31+
"bgTextureActive": "inset_soft",
32+
"bgImgOpacityActive": "30",
33+
"borderColorActive": "ffaf0f",
34+
"fcActive": "ffffff",
35+
"iconColorActive": "222222",
36+
"bgColorHighlight": "eeeeee",
37+
"bgTextureHighlight": "highlight_soft",
38+
"bgImgOpacityHighlight": "80",
39+
"borderColorHighlight": "cccccc",
40+
"fcHighlight": "2e7db2",
41+
"iconColorHighlight": "4b8e0b",
42+
"bgColorError": "ffc73d",
43+
"bgTextureError": "glass",
44+
"bgImgOpacityError": "40",
45+
"borderColorError": "ffb73d",
46+
"fcError": "111111",
47+
"iconColorError": "a83300",
48+
"bgColorOverlay": "5c5c5c",
49+
"bgTextureOverlay": "flat",
50+
"bgImgOpacityOverlay": "50",
51+
"opacityOverlay": "80",
52+
"bgColorShadow": "cccccc",
53+
"bgTextureShadow": "flat",
54+
"bgImgOpacityShadow": "30",
55+
"opacityShadow": "60",
56+
"thicknessShadow": "7px",
57+
"offsetTopShadow": "-7px",
58+
"offsetLeftShadow": "-7px",
59+
"cornerRadiusShadow": "8px"
60+
}

test/fixtures/vars/ui-lightness.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"ffDefault": "Trebuchet MS,Tahoma,Verdana,Arial,sans-serif",
3+
"fwDefault": "bold",
4+
"fsDefault": "1.1em",
5+
"cornerRadius": "4px",
6+
"bgColorHeader": "f6a828",
7+
"bgTextureHeader": "gloss_wave",
8+
"bgImgOpacityHeader": "35",
9+
"borderColorHeader": "e78f08",
10+
"fcHeader": "ffffff",
11+
"iconColorHeader": "ffffff",
12+
"bgColorContent": "eeeeee",
13+
"bgTextureContent": "highlight_soft",
14+
"bgImgOpacityContent": "100",
15+
"borderColorContent": "dddddd",
16+
"fcContent": "333333",
17+
"iconColorContent": "222222",
18+
"bgColorDefault": "f6f6f6",
19+
"bgTextureDefault": "glass",
20+
"bgImgOpacityDefault": "100",
21+
"borderColorDefault": "cccccc",
22+
"fcDefault": "1c94c4",
23+
"iconColorDefault": "ef8c08",
24+
"bgColorHover": "fdf5ce",
25+
"bgTextureHover": "glass",
26+
"bgImgOpacityHover": "100",
27+
"borderColorHover": "fbcb09",
28+
"fcHover": "c77405",
29+
"iconColorHover": "ef8c08",
30+
"bgColorActive": "ffffff",
31+
"bgTextureActive": "glass",
32+
"bgImgOpacityActive": "65",
33+
"borderColorActive": "fbd850",
34+
"fcActive": "eb8f00",
35+
"iconColorActive": "ef8c08",
36+
"bgColorHighlight": "ffe45c",
37+
"bgTextureHighlight": "highlight_soft",
38+
"bgImgOpacityHighlight": "75",
39+
"borderColorHighlight": "fed22f",
40+
"fcHighlight": "363636",
41+
"iconColorHighlight": "228ef1",
42+
"bgColorError": "b81900",
43+
"bgTextureError": "diagonals_thick",
44+
"bgImgOpacityError": "18",
45+
"borderColorError": "cd0a0a",
46+
"fcError": "ffffff",
47+
"iconColorError": "ffd27a",
48+
"bgColorOverlay": "666666",
49+
"bgTextureOverlay": "diagonals_thick",
50+
"bgImgOpacityOverlay": "20",
51+
"opacityOverlay": "50",
52+
"bgColorShadow": "000000",
53+
"bgTextureShadow": "flat",
54+
"bgImgOpacityShadow": "10",
55+
"opacityShadow": "20",
56+
"thicknessShadow": "5px",
57+
"offsetTopShadow": "-5px",
58+
"offsetLeftShadow": "-5px",
59+
"cornerRadiusShadow": "5px"
60+
}

test/themeroller-themegallery.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

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

test/themeroller.js

+50-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
var fs = require( "fs" ),
3+
var fs = require( "node:fs/promises" ),
44
ThemeRoller = require( "../lib/themeroller" );
55

66
module.exports = {
@@ -38,3 +38,52 @@ module.exports = {
3838
}
3939
}
4040
};
41+
42+
const themeRollerTests = module.exports[ "test: ThemeRoller" ] = {};
43+
44+
( function() {
45+
function dropThemeUrl( cssSource ) {
46+
return cssSource.replace( /\n\s*\* To view and modify this theme, visit http:\/\/jqueryui\.com\/themeroller\/[^\n]+\n/, "\n" );
47+
}
48+
49+
[ "1.12.1", "1.13.2" ].forEach( ( jQueryUiVersion ) => {
50+
let theme;
51+
52+
themeRollerTests[ `with jQuery UI ${ jQueryUiVersion }` ] = {
53+
async setUp( callback ) {
54+
const varsString = await fs.readFile( `${ __dirname }/fixtures/vars/smoothness.json`, "utf-8" );
55+
const vars = JSON.parse( varsString );
56+
57+
theme = new ThemeRoller( { vars, version: jQueryUiVersion } );
58+
callback();
59+
},
60+
61+
async [ "should instantiate" ]( test ) {
62+
test.ok( theme instanceof ThemeRoller );
63+
test.done();
64+
},
65+
66+
async [ "should generate the theme CSS" ]( test ) {
67+
const smoothnessCssFixture = await fs.readFile( `${ __dirname }/fixtures/jquery-ui-${ jQueryUiVersion }/themes/smoothness.css`, "utf-8" );
68+
69+
test.equal(
70+
dropThemeUrl( theme.css() ),
71+
dropThemeUrl( smoothnessCssFixture )
72+
);
73+
test.done();
74+
},
75+
76+
async [ "should generate images" ]( test ) {
77+
theme.generateImages( function( error, images ) {
78+
try {
79+
test.strictEqual( error, null );
80+
test.ok( images && typeof images === "object" );
81+
} finally {
82+
test.done();
83+
}
84+
} );
85+
}
86+
};
87+
} );
88+
89+
} )();

0 commit comments

Comments
 (0)