@@ -13,7 +13,15 @@ import { format, doc } from "prettier";
1313const { printDocToString } = doc . printer ;
1414
1515const pluginPath = resolve ( __dirname , "../dist/index.js" ) ;
16- export function testSample ( testFolder : string , exclusive ?: boolean ) {
16+ export function testSampleWithOptions ( {
17+ testFolder,
18+ exclusive,
19+ prettierOptions = { }
20+ } : {
21+ testFolder : string ;
22+ exclusive ?: boolean ;
23+ prettierOptions ?: any ;
24+ } ) {
1725 const itOrItOnly = exclusive ? it . only : it ;
1826 const inputPath = resolve ( testFolder , "_input.java" ) ;
1927 const expectedPath = resolve ( testFolder , "_output.java" ) ;
@@ -31,7 +39,8 @@ export function testSample(testFolder: string, exclusive?: boolean) {
3139 itOrItOnly ( `can format <${ relativeInputPath } >` , async ( ) => {
3240 const actual = await format ( inputContents , {
3341 parser : "java" ,
34- plugins : [ pluginPath ]
42+ plugins : [ pluginPath ] ,
43+ ...prettierOptions
3544 } ) ;
3645
3746 expect ( actual ) . to . equal ( expectedContents ) ;
@@ -40,17 +49,23 @@ export function testSample(testFolder: string, exclusive?: boolean) {
4049 it ( `Performs a stable formatting for <${ relativeInputPath } >` , async ( ) => {
4150 const onePass = await format ( inputContents , {
4251 parser : "java" ,
43- plugins : [ pluginPath ]
52+ plugins : [ pluginPath ] ,
53+ ...prettierOptions
4454 } ) ;
4555
4656 const secondPass = await format ( onePass , {
4757 parser : "java" ,
48- plugins : [ pluginPath ]
58+ plugins : [ pluginPath ] ,
59+ ...prettierOptions
4960 } ) ;
5061 expect ( onePass ) . to . equal ( secondPass ) ;
5162 } ) ;
5263}
5364
65+ export function testSample ( testFolder : string , exclusive ?: boolean ) {
66+ testSampleWithOptions ( { testFolder, exclusive } ) ;
67+ }
68+
5469export function testRepositorySample (
5570 testFolder : string ,
5671 command : string ,
0 commit comments