test: add tests for `--stdin-filepath`
parent
50a26900de
commit
08460e5ca5
|
@ -0,0 +1,19 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`format correctly if stdin content compatible with stdin-filepath 1`] = `
|
||||
".name {
|
||||
display: none;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`format correctly if stdin content compatible with stdin-filepath 2`] = `""`;
|
||||
|
||||
exports[`throw error if stdin content incompatible with stdin-filepath 1`] = `""`;
|
||||
|
||||
exports[`throw error if stdin content incompatible with stdin-filepath 2`] = `
|
||||
"stdin: SyntaxError: Unexpected token (1:1)
|
||||
> 1 | .name { display: none; }
|
||||
| ^
|
||||
"
|
||||
`;
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
const runPrettier = require("../runPrettier");
|
||||
|
||||
test("format correctly if stdin content compatible with stdin-filepath", () => {
|
||||
const result = runPrettier(
|
||||
"cli",
|
||||
["--no-color", "--stdin-filepath", "abc.css"],
|
||||
{ input: ".name { display: none; }" } // css
|
||||
);
|
||||
|
||||
expect(result.stdout).toMatchSnapshot();
|
||||
expect(result.stderr).toMatchSnapshot();
|
||||
expect(result.status).toEqual(0);
|
||||
});
|
||||
|
||||
test("throw error if stdin content incompatible with stdin-filepath", () => {
|
||||
const result = runPrettier(
|
||||
"cli",
|
||||
["--no-color", "--stdin-filepath", "abc.js"],
|
||||
{ input: ".name { display: none; }" } // css
|
||||
);
|
||||
|
||||
expect(result.stdout).toMatchSnapshot();
|
||||
expect(result.stderr).toMatchSnapshot();
|
||||
expect(result.status).not.toEqual(0);
|
||||
});
|
Loading…
Reference in New Issue