35
35
@ NpmTest
36
36
class PrettierFormatterStepTest extends ResourceHarness {
37
37
38
+ private static final String PRETTIER_VERSION_2 = PrettierFormatterStep .DEFAULT_VERSION ;
39
+
40
+ private static final String PRETTIER_VERSION_3 = "3.0.0" ;
41
+
38
42
@ NpmTest
39
43
@ Nested
40
44
class PrettierFormattingOfFileTypesIsWorking extends NpmFormatterStepCommonTests {
@@ -77,15 +81,16 @@ private void runTestUsingPrettier(String fileType, Map<String, String> dependenc
77
81
@ Nested
78
82
class SpecificPrettierFormatterStepTests extends NpmFormatterStepCommonTests {
79
83
80
- @ Test
81
- void parserInferenceBasedOnExplicitFilepathIsWorking () throws Exception {
84
+ @ ParameterizedTest (name = "{index}: parser inference based on explicit filepath is working with prettier {0}" )
85
+ @ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
86
+ void parserInferenceBasedOnExplicitFilepathIsWorking (String prettierVersion ) throws Exception {
82
87
String filedir = "npm/prettier/filetypes/json/" ;
83
88
84
89
final String dirtyFile = filedir + "json.dirty" ;
85
90
final String cleanFile = filedir + "json.clean" ;
86
91
87
92
final FormatterStep formatterStep = PrettierFormatterStep .create (
88
- PrettierFormatterStep . defaultDevDependencies ( ),
93
+ ImmutableMap . of ( "prettier" , prettierVersion ),
89
94
TestProvisioner .mavenCentral (),
90
95
projectDir (),
91
96
buildDir (),
@@ -98,15 +103,16 @@ void parserInferenceBasedOnExplicitFilepathIsWorking() throws Exception {
98
103
}
99
104
}
100
105
101
- @ Test
102
- void parserInferenceBasedOnFilenameIsWorking () throws Exception {
106
+ @ ParameterizedTest (name = "{index}: parser inference based on filename is working with prettier {0}" )
107
+ @ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
108
+ void parserInferenceBasedOnFilenameIsWorking (String prettierVersion ) throws Exception {
103
109
String filedir = "npm/prettier/filename/" ;
104
110
105
111
final String dirtyFile = filedir + "dirty.json" ;
106
112
final String cleanFile = filedir + "clean.json" ;
107
113
108
114
final FormatterStep formatterStep = PrettierFormatterStep .create (
109
- PrettierFormatterStep . defaultDevDependencies ( ),
115
+ ImmutableMap . of ( "prettier" , prettierVersion ),
110
116
TestProvisioner .mavenCentral (),
111
117
projectDir (),
112
118
buildDir (),
@@ -142,13 +148,13 @@ class PrettierFormattingOptionsAreWorking extends NpmFormatterStepCommonTests {
142
148
143
149
private static final String FILEDIR = "npm/prettier/config/" ;
144
150
145
- void runFormatTest (PrettierConfig config , String cleanFileNameSuffix ) throws Exception {
151
+ void runFormatTest (String prettierVersion , PrettierConfig config , String cleanFileNameSuffix ) throws Exception {
146
152
147
153
final String dirtyFile = FILEDIR + "typescript.dirty" ;
148
154
final String cleanFile = FILEDIR + "typescript." + cleanFileNameSuffix + ".clean" ;
149
155
150
156
final FormatterStep formatterStep = PrettierFormatterStep .create (
151
- PrettierFormatterStep . defaultDevDependencies ( ),
157
+ ImmutableMap . of ( "prettier" , prettierVersion ),
152
158
TestProvisioner .mavenCentral (),
153
159
projectDir (),
154
160
buildDir (),
@@ -161,20 +167,26 @@ void runFormatTest(PrettierConfig config, String cleanFileNameSuffix) throws Exc
161
167
}
162
168
}
163
169
164
- @ Test
165
- void defaultsAreApplied () throws Exception {
166
- runFormatTest (new PrettierConfig (null , ImmutableMap .of ("parser" , "typescript" )), "defaults" );
170
+ @ ParameterizedTest (name = "{index}: defaults are applied with prettier {0}" )
171
+ @ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
172
+ void defaultsAreApplied (String prettierVersion ) throws Exception {
173
+ runFormatTest (prettierVersion , new PrettierConfig (null , ImmutableMap .of ("parser" , "typescript" )), "defaults_prettier_" + major (prettierVersion ));
167
174
}
168
175
169
- @ Test
170
- void configFileOptionsAreApplied () throws Exception {
171
- runFormatTest (new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), null ), "configfile" );
176
+ @ ParameterizedTest (name = "{index}: config file options are applied with prettier {0}" )
177
+ @ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
178
+ void configFileOptionsAreApplied (String prettierVersion ) throws Exception {
179
+ runFormatTest (prettierVersion , new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), null ), "configfile_prettier_" + major (prettierVersion ));
172
180
}
173
181
174
- @ Test
175
- void configFileOptionsCanBeOverriden () throws Exception {
176
- runFormatTest (new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), ImmutableMap .of ("printWidth" , 300 )), "override" );
182
+ @ ParameterizedTest (name = "{index}: config file options can be overriden with prettier {0}" )
183
+ @ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
184
+ void configFileOptionsCanBeOverriden (String prettierVersion ) throws Exception {
185
+ runFormatTest (prettierVersion , new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), ImmutableMap .of ("printWidth" , 300 )), "override_prettier_" + major (prettierVersion ));
177
186
}
178
187
188
+ private String major (String semVer ) {
189
+ return semVer .split ("\\ ." )[0 ];
190
+ }
179
191
}
180
192
}
0 commit comments