|
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.
|
@@ -358,6 +358,54 @@ void autodetectNpmrcFileConfig(String prettierVersion) throws IOException {
|
358 | 358 | Assertions.assertThat(spotlessApply.getOutput()).containsPattern("Running npm command.*npm install.* failed with exit code: 1");
|
359 | 359 | }
|
360 | 360 |
|
| 361 | + @ParameterizedTest(name = "{index}: verifyCleanAndSpotlessWorks with prettier {0}") |
| 362 | + @ValueSource(strings = {PRETTIER_VERSION_2, PRETTIER_VERSION_3}) |
| 363 | + void verifyCleanAndSpotlessWorks(String prettierVersion) throws IOException { |
| 364 | + setFile("build.gradle").toLines( |
| 365 | + "plugins {", |
| 366 | + " id 'com.diffplug.spotless'", |
| 367 | + "}", |
| 368 | + "repositories { mavenCentral() }", |
| 369 | + "def prettierConfig = [:]", |
| 370 | + "prettierConfig['printWidth'] = 20", |
| 371 | + "prettierConfig['parser'] = 'typescript'", |
| 372 | + "spotless {", |
| 373 | + " format 'mytypescript', {", |
| 374 | + " target 'test.ts'", |
| 375 | + " prettier('" + prettierVersion + "').config(prettierConfig)", |
| 376 | + " }", |
| 377 | + "}"); |
| 378 | + setFile("test.ts").toResource("npm/prettier/config/typescript.dirty"); |
| 379 | + final BuildResult spotlessApply = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build(); |
| 380 | + Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL"); |
| 381 | + final BuildResult spotlessApply2 = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build(); |
| 382 | + Assertions.assertThat(spotlessApply2.getOutput()).contains("BUILD SUCCESSFUL"); |
| 383 | + } |
| 384 | + |
| 385 | + @ParameterizedTest(name = "{index}: verifyCleanAndSpotlessWithNpmInstallCacheWorks with prettier {0}") |
| 386 | + @ValueSource(strings = {PRETTIER_VERSION_2, PRETTIER_VERSION_3}) |
| 387 | + void verifyCleanAndSpotlessWithNpmInstallCacheWorks(String prettierVersion) throws IOException { |
| 388 | + setFile("build.gradle").toLines( |
| 389 | + "plugins {", |
| 390 | + " id 'com.diffplug.spotless'", |
| 391 | + "}", |
| 392 | + "repositories { mavenCentral() }", |
| 393 | + "def prettierConfig = [:]", |
| 394 | + "prettierConfig['printWidth'] = 20", |
| 395 | + "prettierConfig['parser'] = 'typescript'", |
| 396 | + "spotless {", |
| 397 | + " format 'mytypescript', {", |
| 398 | + " target 'test.ts'", |
| 399 | + " prettier('" + prettierVersion + "').npmInstallCache().config(prettierConfig)", |
| 400 | + " }", |
| 401 | + "}"); |
| 402 | + setFile("test.ts").toResource("npm/prettier/config/typescript.dirty"); |
| 403 | + final BuildResult spotlessApply = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build(); |
| 404 | + Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL"); |
| 405 | + final BuildResult spotlessApply2 = gradleRunner().withArguments("--stacktrace", "clean", "spotlessApply").build(); |
| 406 | + Assertions.assertThat(spotlessApply2.getOutput()).contains("BUILD SUCCESSFUL"); |
| 407 | + } |
| 408 | + |
361 | 409 | @ParameterizedTest(name = "{index}: autodetectNpmrcFileConfig with prettier {0}")
|
362 | 410 | @ValueSource(strings = {PRETTIER_VERSION_2, PRETTIER_VERSION_3})
|
363 | 411 | void pickupNpmrcFileConfig(String prettierVersion) throws IOException {
|
|
0 commit comments