Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/test/normalizeOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('Matches CSS length values of the supported unit values (px, em, rem)',
'Correctly matches length values with supported units: %s',
(input, expected) => {
expect(LENGTH_REGEX.test(input)).toBeTruthy();
// Wrapped in JSON.stringify() to work around Jest bug.
// https://github.com/facebook/jest/issues/5998
expect(JSON.stringify(input.match(LENGTH_REGEX))).toEqual(JSON.stringify(expected));
},
);
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const run = (input, output, opts, plugin = tidyColumns) => (
postcss([plugin(opts)])
.process(input, { from: undefined })
.then((result) => {
expect(result.css).toEqual(output);
expect(result.css.replace(/\s+/g, ' ')).toEqual(output);
expect(result.warnings().length).toBe(0);
})
);
Expand Down
2 changes: 1 addition & 1 deletion test/tidy-function.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Pattern to match `tidy-*` functions in declaration values', () => {
'Matches %s',
(input, expected) => {
expect(FUNCTION_REGEX.test(input)).toBeTruthy();
// Wrapped in JSON.stringify() to work around Jest bug.
// https://github.com/facebook/jest/issues/5998
expect(JSON.stringify(input.match(FUNCTION_REGEX))).toEqual(JSON.stringify(expected));
},
);
Expand Down
34 changes: 5 additions & 29 deletions test/tidy-propagation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ describe('The `!tidy` signals a declaration should be duplicated inside any conf
'A property declaration is duplicated as expected',
() => runShorthandTest(
'div { tidy-span: 3 !tidy; }',
`div { tidy-span: 3; }
@media (min-width: 768px) {
div { tidy-span: 3; } }
@media (min-width: 1024px) {
div { tidy-span: 3; } }`,
'div { tidy-span: 3; } @media (min-width: 768px) { div { tidy-span: 3; } } @media (min-width: 1024px) { div { tidy-span: 3; } }',
typicalWithBreakpoints,
),
);
Expand All @@ -47,11 +43,7 @@ describe('The `!tidy` signals a declaration should be duplicated inside any conf
'A property declaration with escaped ! (\!tidy) is duplicated as expected',
() => runShorthandTest(
'div { tidy-span: 3 \!tidy; }',
`div { tidy-span: 3; }
@media (min-width: 768px) {
div { tidy-span: 3; } }
@media (min-width: 1024px) {
div { tidy-span: 3; } }`,
'div { tidy-span: 3; } @media (min-width: 768px) { div { tidy-span: 3; } } @media (min-width: 1024px) { div { tidy-span: 3; } }',
typicalWithBreakpoints,
),
);
Expand All @@ -60,13 +52,7 @@ describe('The `!tidy` signals a declaration should be duplicated inside any conf
'A function declaration is duplicated as expected',
() => runShorthandTest(
'div { width: calc(tidy-span(3) + 2rem) !tidy; }',
`div { width: calc(tidy-span(3) + 2rem); }
@media (min-width: 768px) {
div { width: calc(tidy-span(3) + 2rem); } }
@media (min-width: 1024px) {
div { width: calc(tidy-span(3) + 2rem); } }
@media (min-width: 90rem) {
div { width: calc(tidy-span-full(3) + 2rem); } }`,
'div { width: calc(tidy-span(3) + 2rem); } @media (min-width: 768px) { div { width: calc(tidy-span(3) + 2rem); } } @media (min-width: 1024px) { div { width: calc(tidy-span(3) + 2rem); } } @media (min-width: 90rem) { div { width: calc(tidy-span-full(3) + 2rem); } }',
typicalWithBreakpoints,
),
);
Expand All @@ -75,11 +61,7 @@ describe('The `!tidy` signals a declaration should be duplicated inside any conf
'A non-tidy declaration is duplicated as expected',
() => runShorthandTest(
'div { width: 14px !tidy; }',
`div { width: 14px; }
@media (min-width: 768px) {
div { width: 14px; } }
@media (min-width: 1024px) {
div { width: 14px; } }`,
'div { width: 14px; } @media (min-width: 768px) { div { width: 14px; } } @media (min-width: 1024px) { div { width: 14px; } }',
typicalWithBreakpoints,
),
);
Expand All @@ -106,13 +88,7 @@ describe('The `!tidy` signals a declaration should be duplicated inside any conf
'Adds tidy-offset-full() when a !tidy declaration contains tidy-offset()',
() => runShorthandTest(
'div { width: calc(tidy-offset(3) + 2rem) !tidy; }',
`div { width: calc(tidy-offset(3) + 2rem); }
@media (min-width: 768px) {
div { width: calc(tidy-offset(3) + 2rem); } }
@media (min-width: 1024px) {
div { width: calc(tidy-offset(3) + 2rem); } }
@media (min-width: 90rem) {
div { width: calc(tidy-offset-full(3) + 2rem); } }`,
'div { width: calc(tidy-offset(3) + 2rem); } @media (min-width: 768px) { div { width: calc(tidy-offset(3) + 2rem); } } @media (min-width: 1024px) { div { width: calc(tidy-offset(3) + 2rem); } } @media (min-width: 90rem) { div { width: calc(tidy-offset-full(3) + 2rem); } }',
typicalWithBreakpoints,
),
);
Expand Down
10 changes: 3 additions & 7 deletions test/tidy-property.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ describe('The `tidy-offset-*` properties are replaced and their values reflect t
'The `tidy-offset-left` property is replaced.',
() => run(
'div { tidy-offset-left: 1; }',
`div { margin-left: calc(((100vw - 0.625rem * 2) / 12 - 1.1458rem) + 1.25rem); }
@media (min-width: 90rem) {
div { margin-left: calc(((90rem - 0.625rem * 2) / 12 - 1.1458rem) + 1.25rem); } }`,
'div { margin-left: calc(((100vw - 0.625rem * 2) / 12 - 1.1458rem) + 1.25rem); } @media (min-width: 90rem) { div { margin-left: calc(((90rem - 0.625rem * 2) / 12 - 1.1458rem) + 1.25rem); } }',
typical,
),
);
Expand All @@ -22,9 +20,7 @@ describe('The `tidy-offset-*` properties are replaced and their values reflect t
'The `tidy-offset-right` property is replaced.',
() => run(
'div { tidy-offset-right: 2; }',
`div { margin-right: calc((((100vw - 0.625rem * 2) / 12 - 1.1458rem) * 2) + 1.25rem * 2); }
@media (min-width: 90rem) {
div { margin-right: calc((((90rem - 0.625rem * 2) / 12 - 1.1458rem) * 2) + 1.25rem * 2); } }`,
'div { margin-right: calc((((100vw - 0.625rem * 2) / 12 - 1.1458rem) * 2) + 1.25rem * 2); } @media (min-width: 90rem) { div { margin-right: calc((((90rem - 0.625rem * 2) / 12 - 1.1458rem) * 2) + 1.25rem * 2); } }',
typical,
),
);
Expand Down Expand Up @@ -106,7 +102,7 @@ describe('Pattern to match the `tidy-offset-*` property', () => {
'Matches %s',
(input, expected) => {
expect(OFFSET_REGEX.test(input)).toBeTruthy();
// Wrapped in JSON.stringify() to work around Jest bug.
// https://github.com/facebook/jest/issues/5998
expect(JSON.stringify(input.match(OFFSET_REGEX))).toEqual(JSON.stringify(expected));
},
);
Expand Down
2 changes: 2 additions & 0 deletions test/tidy-shorthand-property.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ describe('Matches valid tidy-column shorthand values', () => {
'Matches tidy-column: %s',
(input, expected) => {
expect(COLUMNS_REGEX.test(input)).toBeTruthy();
// https://github.com/facebook/jest/issues/5998
expect(JSON.stringify(input.match(COLUMNS_REGEX))).toEqual(JSON.stringify(expected));
},
);
Expand Down Expand Up @@ -183,6 +184,7 @@ describe('Matches valid tidy-offset shorthand values', () => {
'Matches tidy-offset: %s',
(input, expected) => {
expect(OFFSET_REGEX.test(input)).toBeTruthy();
// https://github.com/facebook/jest/issues/5998
expect(JSON.stringify(input.match(OFFSET_REGEX))).toEqual(JSON.stringify(expected));
},
);
Expand Down
2 changes: 1 addition & 1 deletion test/tidy-var.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('Matches tidy-var() functions', () => {
'Matches %s',
(input, expected) => {
expect(VAR_FUNCTION_REGEX.test(input)).toBeTruthy();
// Wrapped in JSON.stringify() to work around Jest bug.
// https://github.com/facebook/jest/issues/5998
expect(JSON.stringify(input.match(VAR_FUNCTION_REGEX))).toEqual(JSON.stringify(expected));
},
);
Expand Down