-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported test suite: plugin-default-options
- Loading branch information
1 parent
51c4400
commit 17406c9
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["./plugin"] | ||
} |
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,30 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
languages: [ | ||
{ | ||
name: "foo", | ||
parsers: ["foo-parser"], | ||
extensions: [".foo"], | ||
}, | ||
], | ||
defaultOptions: { | ||
tabWidth: 8, | ||
bracketSpacing: false, | ||
}, | ||
parsers: { | ||
"foo-parser": { | ||
parse: (text) => ({ text }), | ||
astFormat: "foo-ast", | ||
}, | ||
}, | ||
printers: { | ||
"foo-ast": { | ||
print: (path, options) => | ||
JSON.stringify({ | ||
tabWidth: options.tabWidth, | ||
bracketSpacing: options.bracketSpacing, | ||
}), | ||
}, | ||
}, | ||
}; |
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,39 @@ | ||
import { runCli } from "../utils"; | ||
|
||
describe("plugin default options should work", () => { | ||
runCli("plugin-default-options", [ | ||
"--stdin-filepath", | ||
"example.foo", | ||
"--plugin=./plugin.cjs", | ||
"--no-editorconfig", | ||
], { | ||
input: "hello-world", | ||
}).test({ | ||
stdout: JSON.stringify({ | ||
tabWidth: 8, | ||
bracketSpacing: false, | ||
}), | ||
stderr: "", | ||
status: 0, | ||
write: [], | ||
}); | ||
}); | ||
|
||
describe("overriding plugin default options should work", () => { | ||
runCli("plugin-default-options", [ | ||
"--stdin-filepath", | ||
"example.foo", | ||
"--plugin=./plugin.cjs", | ||
"--tab-width=4", | ||
], { | ||
input: "hello-world", | ||
}).test({ | ||
stdout: JSON.stringify({ | ||
tabWidth: 4, | ||
bracketSpacing: false, | ||
}), | ||
stderr: "", | ||
status: 0, | ||
write: [], | ||
}); | ||
}); |