FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test(postcss-convert-values): improve coverage · cssnano/cssnano@5522fce · GitHub

Repository navigation

Commit 5522fce

Browse files
committed
test(postcss-convert-values): improve coverage
1 parent 6898320 commit 5522fce

11 files changed

Lines changed: 44 additions & 8 deletions

File tree

‎packages/postcss-convert-values/src/lib/convert.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export const lengthConv = new Map([
1+
const lengthConv = new Map([
22
['in', 288],
33
['px', 3],
44
['pt', 4],
55
['pc', 48],
66
]);
77

8-
export const metricConv = new Map([
8+
const metricConv = new Map([
99
['cm', 40],
1010
['mm', 4],
1111
['q', 1],

packages/postcss-convert-values/src/lib/parse-syntax.js renamed to packages/postcss-convert-values/src/lib/parseSyntax.js

File renamed without changes.

‎packages/postcss-convert-values/src/lib/transform.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cssnanoUtils from 'cssnano-utils';
2-
import { syntaxAllowsPercentage } from './parse-syntax.js';
2+
import { syntaxAllowsPercentage } from './parseSyntax.js';
33
import { findReplacements, stripVendorPrefix } from './findReplacements.js';
44

55
const { applyEdits } = cssnanoUtils;

‎packages/postcss-convert-values/test/atProperty.test.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,4 +500,12 @@ describe('@property initial-value', () => {
500500
`@property --test{syntax:/* a */ '<length>' /* b */;inherits:false;initial-value:0;}`
501501
)
502502
);
503+
504+
test(
505+
'should reuse cached syntax evaluation for multiple initial-value declarations in @property',
506+
processCSS(
507+
`@property --percent{syntax:'<percentage>';inherits:false;initial-value:0%;initial-value:0%;}`,
508+
`@property --percent{syntax:'<percentage>';inherits:false;initial-value:0%;initial-value:0%;}`
509+
)
510+
);
503511
});

‎packages/postcss-convert-values/test/calcAndFunctions.test.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ describe('Escaped and case-insensitive function names', () => {
131131

132132
const mozResult = await processor('div{width:-moz-calc(100% - 0px)}');
133133
assert.equal(mozResult.css, 'div{width:-moz-calc(100% - 0px)}');
134+
135+
const oResult = await processor('div{width:-o-calc(100% - 0px)}');
136+
assert.equal(oResult.css, 'div{width:-o-calc(100% - 0px)}');
134137
});
135138

136139
test('should preserve zero units in vendor-prefixed conic-gradient names', async () => {
@@ -383,6 +386,13 @@ describe('Math functions and preserving units', () => {
383386
)
384387
);
385388

389+
test(
390+
'should preserve zero length and percentage units in anchor-size() fallbacks',
391+
passthroughCSS(
392+
'h1{width:anchor-size(--target width, 0px);height:anchor-size(--target height, 0%);top:anchor-size(self-inline, 0rem)}'
393+
)
394+
);
395+
386396
test(
387397
'should preserve zero percentage inside contrast-color()',
388398
passthroughCSS('h1{color:contrast-color(0%)}')
@@ -394,6 +404,21 @@ describe('Math functions and preserving units', () => {
394404
'h1{view-timeline-inset:view(0px 0px);animation-range:view(0%)}'
395405
)
396406
);
407+
408+
test(
409+
'should preserve zero percentage in animation-timeline view() inset',
410+
passthroughCSS('h1{animation-timeline:view(0% 0%)}')
411+
);
412+
413+
test(
414+
'should convert percentage to unitless zero in view-timeline-inset',
415+
processCSS('h1{view-timeline-inset:0%}', 'h1{view-timeline-inset:0}')
416+
);
417+
418+
test(
419+
'should convert multiple percentages to unitless zeros in view-timeline-inset',
420+
processCSS('h1{view-timeline-inset:0% 0%}', 'h1{view-timeline-inset:0 0}')
421+
);
397422
});
398423

399424
describe('CSS custom property fallbacks (var)', () => {

‎packages/postcss-convert-values/test/timeAndLengthUnits.test.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ describe('Length and viewport units', () => {
166166
passthroughCSS('h1{-webkit-line-height:0px;-webkit-line-height:0%}')
167167
);
168168

169+
test(
170+
'should preserve zero units in -o- prefixed line-height',
171+
passthroughCSS('h1{-o-line-height:0px;-o-line-height:0%}')
172+
);
173+
169174
test(
170175
'should convert metric units (mm to cm)',
171176
processCSS(

‎packages/postcss-convert-values/types/lib/convert.d.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export declare const lengthConv: Map<string, number>;
2-
export declare const metricConv: Map<string, number>;
31
export declare const timeConv: Map<string, number>;
42
export declare const angleConv: Map<string, number>;
53
export declare const freqConv: Map<string, number>;

‎packages/postcss-convert-values/types/lib/convert.d.ts.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/postcss-convert-values/types/lib/parse-syntax.d.ts.map‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/postcss-convert-values/types/lib/parse-syntax.d.ts renamed to packages/postcss-convert-values/types/lib/parseSyntax.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/** @param {string} value @return {boolean} */
22
export declare function syntaxAllowsPercentage(value: string): boolean;
3-
//# sourceMappingURL=parse-syntax.d.ts.map
3+
//# sourceMappingURL=parseSyntax.d.ts.map

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL