-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added the
implementation
option (#511)
- Loading branch information
Showing
7 changed files
with
153 additions
and
1 deletion.
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
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,52 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`"implementation" option should work with a custom instance of PostCSS: css 1`] = ` | ||
"a { | ||
color: black; | ||
} | ||
a { | ||
color: red; | ||
} | ||
a { | ||
color: green; | ||
} | ||
a { | ||
color: blue; | ||
} | ||
.class { | ||
-x-border-color: blue blue *; | ||
-x-color: * #fafafa; | ||
} | ||
.class-foo { | ||
-z-border-color: blue blue *; | ||
-z-color: * #fafafa; | ||
} | ||
.phone { | ||
&_title { | ||
width: 500px; | ||
@media (max-width: 500px) { | ||
width: auto; | ||
} | ||
body.is_dark & { | ||
color: white; | ||
} | ||
} | ||
img { | ||
display: block; | ||
} | ||
} | ||
" | ||
`; | ||
|
||
exports[`"implementation" option should work with a custom instance of PostCSS: errors 1`] = `Array []`; | ||
|
||
exports[`"implementation" option should work with a custom instance of PostCSS: warnings 1`] = `Array []`; |
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,26 @@ | ||
import postcss from "postcss"; | ||
|
||
import { | ||
compile, | ||
getCompiler, | ||
getErrors, | ||
getCodeFromBundle, | ||
getWarnings, | ||
} from "./helpers"; | ||
|
||
describe('"implementation" option', () => { | ||
it("should work with a custom instance of PostCSS", async () => { | ||
const spy = jest.fn(postcss); | ||
const compiler = getCompiler("./css/index.js", { | ||
// Wrap the spy so it is an instanceof Function | ||
implementation: (...args) => spy(...args), | ||
}); | ||
const stats = await compile(compiler); | ||
const codeFromBundle = getCodeFromBundle("style.css", stats); | ||
|
||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(codeFromBundle.css).toMatchSnapshot("css"); | ||
expect(getWarnings(stats)).toMatchSnapshot("warnings"); | ||
expect(getErrors(stats)).toMatchSnapshot("errors"); | ||
}); | ||
}); |
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