Skip to content

Commit 276c5a7

Browse files
committed
adding more integration tests for typescript extension
1 parent e90dbf6 commit 276c5a7

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.diffplug.gradle.spotless;
1717

18+
import java.io.File;
1819
import java.io.IOException;
1920

2021
import org.junit.Test;
@@ -23,7 +24,7 @@
2324
@Category(NpmTest.class)
2425
public class TypescriptExtensionTest extends GradleIntegrationTest {
2526
@Test
26-
public void integration() throws IOException {
27+
public void useTsfmtInlineConfig() throws IOException {
2728
setFile("build.gradle").toLines(
2829
"buildscript { repositories { mavenCentral() } }",
2930
"plugins {",
@@ -42,4 +43,45 @@ public void integration() throws IOException {
4243
gradleRunner().withArguments("spotlessApply").build();
4344
assertFile("test.ts").sameAsResource("npm/tsfmt/tsfmt/tsfmt.clean");
4445
}
46+
47+
@Test
48+
public void useTsfmtFileConfig() throws IOException {
49+
File formattingFile = setFile("tsfmt.json").toLines(
50+
"{",
51+
" \"indentSize\": 1,",
52+
" \"convertTabsToSpaces\": true",
53+
"}");
54+
setFile("build.gradle").toLines(
55+
"buildscript { repositories { mavenCentral() } }",
56+
"plugins {",
57+
" id 'com.diffplug.gradle.spotless'",
58+
"}",
59+
"spotless {",
60+
" typescript {",
61+
" target 'test.ts'",
62+
" tsfmt().configFile('tsfmt', '" + formattingFile.getAbsolutePath() + "')",
63+
" }",
64+
"}");
65+
setFile("test.ts").toResource("npm/tsfmt/tsfmt/tsfmt.dirty");
66+
gradleRunner().withArguments("--stacktrace", "spotlessApply").build();
67+
assertFile("test.ts").sameAsResource("npm/tsfmt/tsfmt/tsfmt.clean");
68+
}
69+
70+
@Test
71+
public void usePrettier() throws IOException {
72+
setFile("build.gradle").toLines(
73+
"buildscript { repositories { mavenCentral() } }",
74+
"plugins {",
75+
" id 'com.diffplug.gradle.spotless'",
76+
"}",
77+
"spotless {",
78+
" typescript {",
79+
" target 'test.ts'",
80+
" prettier()",
81+
" }",
82+
"}");
83+
setFile("test.ts").toResource("npm/prettier/filetypes/typescript/typescript.dirty");
84+
gradleRunner().withArguments("--stacktrace", "spotlessApply").build();
85+
assertFile("test.ts").sameAsResource("npm/prettier/filetypes/typescript/typescript.clean");
86+
}
4587
}

0 commit comments

Comments
 (0)