forked from zgreen/postcss-critical-css
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ignoreSelectors, fs issue
- Loading branch information
Showing
19 changed files
with
313 additions
and
11 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
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,9 @@ | ||
@critical; | ||
|
||
.foo .bar { | ||
color: green; | ||
} | ||
|
||
.foo { | ||
color: orange; | ||
} |
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,11 @@ | ||
@critical; | ||
|
||
header.top { | ||
background: red; | ||
} | ||
|
||
@media screen and (max-width: 400px) { | ||
header.top { | ||
width: 100%; | ||
} | ||
} |
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,6 @@ | ||
@critical; | ||
|
||
.bar-baz { | ||
color: blue; | ||
font-style: italic; | ||
} |
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,19 @@ | ||
@media screen and (min-width: 1024px) { | ||
.foo { | ||
critical-selector: this; | ||
display: flex; | ||
width: calc(100% - 200px); | ||
} | ||
|
||
.bar { | ||
border: 10px solid gold; | ||
critical-selector: this; | ||
height: 100%; | ||
} | ||
|
||
.baz::before { | ||
content: 'test'; | ||
critical-selector: this; | ||
position: fixed; | ||
} | ||
} |
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,6 @@ | ||
@critical; | ||
|
||
.fs-test-five { | ||
color: blue; | ||
font-family: Times; | ||
} |
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,6 @@ | ||
@critical; | ||
|
||
.fs-test-six { | ||
color: blue; | ||
font-family: Helvetica; | ||
} |
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,11 @@ | ||
@critical; | ||
|
||
.foo { | ||
display: flex; | ||
width: calc(100% - 200px); | ||
} | ||
|
||
.bar { | ||
border: 10px solid gold; | ||
height: 100%; | ||
} |
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,12 @@ | ||
.foo { | ||
color: gold; | ||
height: 100px; | ||
} | ||
|
||
@critical { | ||
|
||
.bar { | ||
color: tomato; | ||
height: 200px; | ||
} | ||
} |
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,68 @@ | ||
|
||
|
||
.foo .bar { | ||
color: green; | ||
} | ||
|
||
.foo { | ||
color: orange; | ||
} | ||
|
||
header.top { | ||
background: red; | ||
} | ||
|
||
@media screen and (max-width: 400px) { | ||
header.top { | ||
width: 100%; | ||
} | ||
} | ||
|
||
.bar-baz { | ||
color: blue; | ||
font-style: italic; | ||
}@media screen and (min-width: 1024px) { | ||
.foo { | ||
display: flex; | ||
width: calc(100% - 200px); | ||
} | ||
} | ||
@media screen and (min-width: 1024px) { | ||
|
||
.bar { | ||
border: 10px solid gold; | ||
height: 100%; | ||
} | ||
} | ||
@media screen and (min-width: 1024px) { | ||
|
||
.baz::before { | ||
content: 'test'; | ||
position: fixed; | ||
} | ||
} | ||
|
||
.fs-test-five { | ||
color: blue; | ||
font-family: Times; | ||
} | ||
|
||
.fs-test-six { | ||
color: blue; | ||
font-family: Helvetica; | ||
} | ||
|
||
.foo { | ||
display: flex; | ||
width: calc(100% - 200px); | ||
} | ||
|
||
.bar { | ||
border: 10px solid gold; | ||
height: 100%; | ||
} | ||
|
||
.bar { | ||
color: tomato; | ||
height: 200px; | ||
} |
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,68 @@ | ||
|
||
|
||
.foo .bar { | ||
color: green; | ||
} | ||
|
||
.foo { | ||
color: orange; | ||
} | ||
|
||
header.top { | ||
background: red; | ||
} | ||
|
||
@media screen and (max-width: 400px) { | ||
header.top { | ||
width: 100%; | ||
} | ||
} | ||
|
||
.bar-baz { | ||
color: blue; | ||
font-style: italic; | ||
}@media screen and (min-width: 1024px) { | ||
.foo { | ||
display: flex; | ||
width: calc(100% - 200px); | ||
} | ||
} | ||
@media screen and (min-width: 1024px) { | ||
|
||
.bar { | ||
border: 10px solid gold; | ||
height: 100%; | ||
} | ||
} | ||
@media screen and (min-width: 1024px) { | ||
|
||
.baz::before { | ||
content: 'test'; | ||
position: fixed; | ||
} | ||
} | ||
|
||
.fs-test-five { | ||
color: blue; | ||
font-family: Times; | ||
} | ||
|
||
.fs-test-six { | ||
color: blue; | ||
font-family: Helvetica; | ||
} | ||
|
||
.foo { | ||
display: flex; | ||
width: calc(100% - 200px); | ||
} | ||
|
||
.bar { | ||
border: 10px solid gold; | ||
height: 100%; | ||
} | ||
|
||
.bar { | ||
color: tomato; | ||
height: 200px; | ||
} |
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 @@ | ||
.test-output-dest{color:blue;font-family:Times} |
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 @@ | ||
.baz{color:green;text-decoration:underline} |
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 @@ | ||
.baz{color:green;text-decoration:underline} |
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,16 @@ | ||
@critical ignore-selectors.critical.actual.css; | ||
|
||
.foo { | ||
color: blue; | ||
font-style: italic; | ||
} | ||
|
||
.bar { | ||
color: tomato; | ||
display: flex; | ||
} | ||
|
||
.baz { | ||
color: green; | ||
text-decoration: underline; | ||
} |
14 changes: 14 additions & 0 deletions
14
test/fixtures/options/ignore-selectors.non-critical.actual.css
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,14 @@ | ||
.foo { | ||
color: blue; | ||
font-style: italic; | ||
} | ||
|
||
.bar { | ||
color: tomato; | ||
display: flex; | ||
} | ||
|
||
.baz { | ||
color: green; | ||
text-decoration: underline; | ||
} |
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,27 @@ | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const postcss = require('postcss'); | ||
const compareCritical = require('./compareCritical'); | ||
const { normalizeOpts } = require('./utils'); | ||
const postcssCriticalCSS = require('..') | ||
|
||
describe('tests for file writing functionality', () => { | ||
it('should be capable of copying critical CSS from multiple sources into a single file without overwrites', async () => { | ||
const fixturePath = path.join(__dirname, 'fixtures/fs'); | ||
const pluginOpts = normalizeOpts({ | ||
outputPath: fixturePath, | ||
outputDest: 'fs.critical.actual.css', | ||
minify: false | ||
}); | ||
const files = await fs.readdir(fixturePath) | ||
const processor = postcss() | ||
.use(postcssCriticalCSS(pluginOpts)) | ||
|
||
for (let file of files) { | ||
const css = await fs.readFile(path.join(fixturePath, file), 'utf8'); | ||
await processor.process(css, { from: file }) | ||
} | ||
|
||
compareCritical(pluginOpts, 'fs') | ||
}) | ||
}) |
Oops, something went wrong.