From 9797943938583afb6c787ad59d9ae79be73346fe Mon Sep 17 00:00:00 2001 From: Thomas Wehr Date: Thu, 23 Jun 2022 22:24:11 +0200 Subject: [PATCH] fix: Theme.name does not match registered name (#6186) (#6226) * fix: Theme.name does not match registered name (#6186) * chore(tests): add test for defineTheme normalizing to lower case --- core/theme.js | 1 + tests/mocha/theme_test.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/core/theme.js b/core/theme.js index d156b1227d9..e5bc08c52bd 100644 --- a/core/theme.js +++ b/core/theme.js @@ -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) { diff --git a/tests/mocha/theme_test.js b/tests/mocha/theme_test.js index 95d61ce0d04..cc29797f112 100644 --- a/tests/mocha/theme_test.js +++ b/tests/mocha/theme_test.js @@ -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'); + }); + }); });