Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: separate integration tests from single plugin tests (#1409)
Most tests that exercise the default preset as a whole were in the cssnano directory, but some were mixed with the individual plugin tests. * To distinguish the effect of each individual plugin, move all remaining integration tests in the cssnano test directory. * Convert tests that only check the effect of a single plugin, to only use that plugin.
- Loading branch information
1 parent
b842e72
commit ffa084e
Showing
8 changed files
with
163 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
'use strict'; | ||
const { test } = require('uvu'); | ||
const processCss = require('./_processCss'); | ||
|
||
test( | ||
'should minify color values in background gradients (preset)', | ||
processCss( | ||
'h1{background:linear-gradient( #ff0000,yellow )}', | ||
'h1{background:linear-gradient(red,#ff0)}' | ||
) | ||
); | ||
|
||
test( | ||
'should minify color values in background gradients (2) (preset)', | ||
processCss( | ||
'h1{background:linear-gradient(yellow, orange), linear-gradient(black, rgba(255, 255, 255, 0))}', | ||
'h1{background:linear-gradient(#ff0,orange),linear-gradient(#000,hsla(0,0%,100%,0))}' | ||
) | ||
); | ||
|
||
test( | ||
'should minify color values in background gradients (3) (preset)', | ||
processCss( | ||
'h1{background:linear-gradient(0deg, yellow, black 40%, red)}', | ||
'h1{background:linear-gradient(0deg,#ff0,#000 40%,red)}' | ||
) | ||
); | ||
|
||
test( | ||
'should minify color values (10)', | ||
processCss( | ||
'h1{text-shadow: 1px 1px 1px #F0FFFF, 1px 1px 1px #F0FFFF}', | ||
'h1{text-shadow:1px 1px 1px azure,1px 1px 1px azure}' | ||
) | ||
); | ||
|
||
test( | ||
'should bail on the "composes" property', | ||
processCss.passthrough('h1{composes:black from "styles"}') | ||
); | ||
|
||
test( | ||
'should not mangle empty strings', | ||
processCss.passthrough('h1{content:""}') | ||
); | ||
|
||
test( | ||
'should passthrough css variables', | ||
processCss.passthrough('h1{color:var(--foo)}') | ||
); | ||
|
||
test( | ||
'should passthrough css variables #2', | ||
processCss.passthrough('h1{color:var(--foo) var(--bar)}') | ||
); | ||
|
||
test( | ||
'should passthrough css variables #3', | ||
processCss.passthrough('h1{color:rgb(var(--foo),255,255)}') | ||
); | ||
|
||
test( | ||
'should passthrough css variables #4', | ||
processCss.passthrough('h1{color:rgb(255,var(--bar),255)}') | ||
); | ||
|
||
test( | ||
'should passthrough css variables #5', | ||
processCss.passthrough('h1{color:rgb(255,255,var(--baz))}') | ||
); | ||
|
||
test( | ||
'should passthrough css variables #6', | ||
processCss.passthrough('h1{color:rgb(var(--foo))}') | ||
); | ||
|
||
test( | ||
'should passthrough env function', | ||
processCss.passthrough('h1{color:rgb(env(foo))}') | ||
); | ||
|
||
test( | ||
'should not minify in lowercase filter properties', | ||
processCss.passthrough( | ||
'h1{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr= #000000,endColorstr= #ffffff)}' | ||
) | ||
); | ||
|
||
test( | ||
'should not minify in uppercase filter properties', | ||
processCss.passthrough( | ||
'h1{FILTER:progid:DXImageTransform.Microsoft.gradient(startColorstr= #000000,endColorstr= #ffffff)}' | ||
) | ||
); | ||
|
||
test.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
const { test } = require('uvu'); | ||
const processCss = require('./_processCss'); | ||
|
||
test( | ||
'should not escape legal characters', | ||
processCss.passthrough('h1{font-family:€42}') | ||
); | ||
|
||
test( | ||
'should not join identifiers in the shorthand property', | ||
processCss.passthrough('h1{font:italic "Bond 007 008 009",sans-serif}') | ||
); | ||
|
||
test( | ||
'should escape special characters if unquoting', | ||
processCss('h1{font-family:"Ahem!"}', 'h1{font-family:Ahem\\!}') | ||
); | ||
|
||
test( | ||
'should not escape multiple special characters', | ||
processCss.passthrough('h1{font-family:"Ahem!!"}') | ||
); | ||
|
||
test( | ||
'should not mangle legal unquoted values', | ||
processCss.passthrough('h1{font-family:\\$42}') | ||
); | ||
|
||
test( | ||
'should not mangle font names', | ||
processCss.passthrough('h1{font-family:Glyphicons Halflings}') | ||
); | ||
|
||
test.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
const { test } = require('uvu'); | ||
const processCss = require('./_processCss'); | ||
|
||
test( | ||
'should trim whitespace from nested functions (preset)', | ||
processCss( | ||
'h1{width:calc(10px - ( 100px / var(--test) ))}', | ||
'h1{width:calc(10px - 100px/var(--test))}' | ||
) | ||
); | ||
|
||
test.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.