Skip to content

Commit

Permalink
fix: Theme.name does not match registered name (#6186) (#6226)
Browse files Browse the repository at this point in the history
* fix: Theme.name does not match registered name (#6186)

* chore(tests): add test for defineTheme normalizing to lower case
  • Loading branch information
derwehr authored Jun 23, 2022
1 parent 233cce8 commit 9797943
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class Theme {
* @return {!Theme} A new Blockly theme.
*/
static defineTheme(name, themeObj) {
name = name.toLowerCase();
const theme = new Theme(name);
let base = themeObj['base'];
if (base) {
Expand Down
7 changes: 7 additions & 0 deletions tests/mocha/theme_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,11 @@ suite('Theme', function() {
this.constants.validatedBlockStyle_(inputStyle), expectedOutput);
});
});

suite('defineTheme', function() {
test('Normalizes to lowercase', function() {
const theme = Blockly.Theme.defineTheme('TEST', {});
chai.assert.equal(theme.name, 'test');
});
});
});

0 comments on commit 9797943

Please sign in to comment.