Skip to content

Commit

Permalink
task/WP-355: Fixing issue with icons on dev/prod sites (#892)
Browse files Browse the repository at this point in the history
* fixing issue with icons all defaulting to icon-applications on dev/prod site

* getting rid of console.logs

---------

Co-authored-by: Taylor Grafft <[email protected]>
  • Loading branch information
tjgrafft and Taylor Grafft authored Nov 1, 2023
1 parent 2254481 commit b51c41f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/utils/doesClassExist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
55 changes: 55 additions & 0 deletions client/src/utils/doesClassExist.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit b51c41f

Please sign in to comment.