diff --git a/client/src/utils/doesClassExist.js b/client/src/utils/doesClassExist.js index b3ddab017..29055efe6 100644 --- a/client/src/utils/doesClassExist.js +++ b/client/src/utils/doesClassExist.js @@ -6,7 +6,11 @@ function doesClassExist(className, stylesheets) { return true; } } else if (typeof stylesheet === 'string') { - if (stylesheet.includes(`.${className}::before`)) { + if ( + //Required to fix issue with dev and prod defaulting to icon-applications for every icon + stylesheet.includes(`.${className}::before`) || + stylesheet.includes(`.${className}:before`) + ) { return true; } } diff --git a/client/src/utils/doesClassExist.test.js b/client/src/utils/doesClassExist.test.js new file mode 100644 index 000000000..d43fb5c6e --- /dev/null +++ b/client/src/utils/doesClassExist.test.js @@ -0,0 +1,55 @@ +import doesClassExist from './doesClassExist'; + +const mockStylesheet = ` +.icon-upload:before { + content: "\\ea57" +} + +.icon-user-reverse:before { + content: "\\ea58" +} + +.icon-user:before { + content: "\\ea59" +} + +.icon-visualization:before { + content: "\\ea5a" +} + +.icon-zoom-in:before { + content: "\\ea5b" +} + +.icon-zoom-out:before { + content: "\\ea5c" +} +`; + +describe('doesClassExist', () => { + it('should return true for existing class in string stylesheet', async () => { + const result = doesClassExist('icon-visualization', [mockStylesheet]); + expect(result).toBe(true); + }); + + it('should return false for non-existing class in string stylesheet', async () => { + const result = doesClassExist('icon-nonexistent', [mockStylesheet]); + expect(result).toBe(false); + }); + + it('should return true for existing class in object stylesheet', async () => { + const mockStylesheetObject = { + 'icon-visualization': true, + }; + const result = doesClassExist('icon-visualization', [mockStylesheetObject]); + expect(result).toBe(true); + }); + + it('should return false for non-existing class in object stylesheet', async () => { + const mockStylesheetObject = { + 'icon-visualization': true, + }; + const result = doesClassExist('icon-nonexistent', [mockStylesheetObject]); + expect(result).toBe(false); + }); +});