15
15
*/
16
16
package com .diffplug .gradle .spotless ;
17
17
18
+ import java .io .File ;
18
19
import java .io .IOException ;
19
20
20
21
import org .junit .Test ;
23
24
@ Category (NpmTest .class )
24
25
public class TypescriptExtensionTest extends GradleIntegrationTest {
25
26
@ Test
26
- public void integration () throws IOException {
27
+ public void useTsfmtInlineConfig () throws IOException {
27
28
setFile ("build.gradle" ).toLines (
28
29
"buildscript { repositories { mavenCentral() } }" ,
29
30
"plugins {" ,
@@ -42,4 +43,45 @@ public void integration() throws IOException {
42
43
gradleRunner ().withArguments ("spotlessApply" ).build ();
43
44
assertFile ("test.ts" ).sameAsResource ("npm/tsfmt/tsfmt/tsfmt.clean" );
44
45
}
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
+ }
45
87
}
0 commit comments