Skip to content

Commit 9dc26a3

Browse files
committed
WIP
1 parent 9569417 commit 9dc26a3

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/JsonExtensionTest.java

+41-25
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@
2121

2222
public class JsonExtensionTest extends GradleIntegrationHarness {
2323
@Test
24-
public void defaultFormatting() throws IOException {
24+
public void defaultFormattingWithCustomTarget() throws IOException {
2525
setFile("build.gradle").toLines(
26-
"buildscript { repositories { mavenCentral() } }",
27-
"plugins {",
28-
" id 'java'",
29-
" id 'com.diffplug.spotless'",
30-
"}",
31-
"spotless {",
32-
" json {" +
33-
" target 'examples/**/*.json'" +
34-
" simple()" +
35-
"}",
36-
"}");
26+
"buildscript { repositories { mavenCentral() } }",
27+
"plugins {",
28+
" id 'com.diffplug.spotless'",
29+
"}",
30+
"spotless {",
31+
" json {",
32+
" simple()",
33+
" target 'examples/**/*.json'" +
34+
" }",
35+
"}");
3736
setFile("src/main/resources/example.json").toResource("json/nestedObjectBefore.json");
3837
setFile("examples/main/resources/example.json").toResource("json/nestedObjectBefore.json");
3938
gradleRunner().withArguments("spotlessApply").build();
@@ -44,21 +43,38 @@ public void defaultFormatting() throws IOException {
4443
@Test
4544
public void formattingWithCustomNumberOfSpaces() throws IOException {
4645
setFile("build.gradle").toLines(
47-
"buildscript { repositories { mavenCentral() } }",
48-
"plugins {",
49-
" id 'java'",
50-
" id 'com.diffplug.spotless'",
51-
"}",
52-
"spotless {",
53-
" json {" +
54-
" target '**/*.json'" +
55-
" simple {" +
56-
" indentWithSpaces(6)" +
57-
" }",
58-
"}",
59-
"}");
46+
"buildscript { repositories { mavenCentral() } }",
47+
"plugins {",
48+
" id 'com.diffplug.spotless'",
49+
"}",
50+
"spotless {",
51+
" json {" +
52+
" simple().indentWithSpaces(6)" +
53+
" target '**/*.json'" +
54+
" }",
55+
"}");
6056
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
6157
gradleRunner().withArguments("spotlessApply").build();
6258
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
6359
}
60+
61+
@Test
62+
public void whenTargetIsFirst() throws IOException {
63+
setFile("build.gradle").toLines(
64+
"buildscript { repositories { mavenCentral() } }",
65+
"plugins {",
66+
" id 'com.diffplug.spotless'",
67+
"}",
68+
"spotless {",
69+
" json {",
70+
" target 'examples/**/*.json'" +
71+
" simple()",
72+
" }",
73+
"}");
74+
setFile("src/main/resources/example.json").toResource("json/nestedObjectBefore.json");
75+
setFile("examples/main/resources/example.json").toResource("json/nestedObjectBefore.json");
76+
gradleRunner().withArguments("spotlessApply").build();
77+
assertFile("src/main/resources/example.json").sameAsResource("json/nestedObjectBefore.json");
78+
assertFile("examples/main/resources/example.json").sameAsResource("json/nestedObjectAfter.json");
79+
}
6480
}

0 commit comments

Comments
 (0)