From 996c068552d6f848efad972018a58df50046d93e Mon Sep 17 00:00:00 2001 From: Hung Viet Nguyen Date: Sun, 21 Aug 2022 10:31:07 +0700 Subject: [PATCH] fix: Convert \r\n, \r to \n to pass all tests on all platforms --- demo/__tests__/style.test.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/demo/__tests__/style.test.tsx b/demo/__tests__/style.test.tsx index f44bf81d..41a7a5c1 100644 --- a/demo/__tests__/style.test.tsx +++ b/demo/__tests__/style.test.tsx @@ -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(); @@ -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; }`);