|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2023 DiffPlug |
| 2 | + * Copyright 2016-2024 DiffPlug |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import java.util.Collections;
|
20 | 20 | import java.util.Map;
|
21 | 21 |
|
22 |
| -import com.diffplug.spotless.SerializableEqualityTester; |
23 |
| -import com.diffplug.spotless.java.GoogleJavaFormatStep; |
24 |
| - |
25 | 22 | import org.junit.jupiter.api.Nested;
|
26 | 23 | import org.junit.jupiter.api.Test;
|
27 | 24 | import org.junit.jupiter.params.ParameterizedTest;
|
28 | 25 | import org.junit.jupiter.params.provider.ValueSource;
|
29 | 26 |
|
30 | 27 | import com.diffplug.common.collect.ImmutableMap;
|
31 | 28 | import com.diffplug.spotless.FormatterStep;
|
32 |
| -import com.diffplug.spotless.ResourceHarness; |
| 29 | +import com.diffplug.spotless.SerializableEqualityTester; |
33 | 30 | import com.diffplug.spotless.StepHarness;
|
34 | 31 | import com.diffplug.spotless.StepHarnessWithFile;
|
35 | 32 | import com.diffplug.spotless.TestProvisioner;
|
36 | 33 | import com.diffplug.spotless.tag.NpmTest;
|
37 | 34 |
|
38 | 35 | @NpmTest
|
39 |
| -class PrettierFormatterStepTest extends ResourceHarness { |
| 36 | +class PrettierFormatterStepTest extends NpmFormatterStepCommonTests { |
40 | 37 |
|
41 | 38 | private static final String PRETTIER_VERSION_2 = PrettierFormatterStep.DEFAULT_VERSION;
|
42 | 39 |
|
@@ -196,27 +193,30 @@ private String major(String semVer) {
|
196 | 193 | @Test
|
197 | 194 | void equality() {
|
198 | 195 | new SerializableEqualityTester() {
|
199 |
| - String groupArtifact = GoogleJavaFormatStep.defaultGroupArtifact(); |
200 |
| - String version = "1.11.0"; |
201 |
| - String style = ""; |
202 |
| - boolean reflowLongStrings = false; |
| 196 | + String prettierVersion = "3.0.0"; |
| 197 | + PrettierConfig config = new PrettierConfig(null, Map.of("parser", "typescript")); |
203 | 198 |
|
204 | 199 | @Override
|
205 | 200 | protected void setupTest(API api) {
|
206 | 201 | // same version == same
|
207 | 202 | api.areDifferentThan();
|
208 | 203 | // change the groupArtifact, and it's different
|
209 |
| - groupArtifact = "io.opil:google-java-format"; |
| 204 | + prettierVersion = "2.8.8"; |
| 205 | + api.areDifferentThan(); |
| 206 | + config = new PrettierConfig(null, Map.of("parser", "css")); |
210 | 207 | api.areDifferentThan();
|
211 | 208 | }
|
212 | 209 |
|
213 | 210 | @Override
|
214 | 211 | protected FormatterStep create() {
|
215 |
| - return PrettierFormatterStep.create(Map.of(), TestProvisioner.mavenCentral(), projectDir(), |
216 |
| - buildDir(), |
217 |
| - null, |
218 |
| - npmPathResolver(), |
219 |
| - ); |
| 212 | + return PrettierFormatterStep.create( |
| 213 | + ImmutableMap.of("prettier", prettierVersion), |
| 214 | + TestProvisioner.mavenCentral(), |
| 215 | + projectDir(), |
| 216 | + buildDir(), |
| 217 | + null, |
| 218 | + npmPathResolver(), |
| 219 | + config); // should select parser based on this name |
220 | 220 | }
|
221 | 221 | }.testEquals();
|
222 | 222 | }
|
|
0 commit comments