Skip to content

Commit

Permalink
fix: Convert \r\n, \r to \n to pass all tests on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh95 committed Aug 21, 2022
1 parent 790bac2 commit 996c068
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions demo/__tests__/style.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { render } from '@testing-library/react';

import App from '../App';

function normalize(str: string) {
return str.replace(/\r\n|\n|\r/g, '\n');
}

describe('Style', () => {
it('should render CSS correctly in JSDOM', () => {
render(<App />);
Expand Down Expand Up @@ -37,19 +41,21 @@ describe('Style', () => {
// Global
// TODO: not implemented yet
// Import
expect(
document.documentElement.outerHTML.replace(/\r\n|\n|\r/g, ''),
).toContain(`._cssModule_1gc0y_1 { color: green;}`);
expect(normalize(document.documentElement.outerHTML)).toContain(
`._cssModule_1gc0y_1 {
color: green;
}`,
);

// Sass
// Global
// TODO: Global SCSS is saved into the `.cache` folder, not in the JSDOM, need to find a way to test it
// Import
expect(document.documentElement.outerHTML)
expect(normalize(document.documentElement.outerHTML))
.toContain(`header .imported-sass {
text-transform: uppercase;
}`);
expect(document.documentElement.outerHTML)
expect(normalize(document.documentElement.outerHTML))
.toContain(`header .imported-sass {
color: pink;
}`);
Expand Down

0 comments on commit 996c068

Please sign in to comment.