Skip to content

Commit 2d67450

Browse files
committed
Tests: inject language
1 parent c9aba16 commit 2d67450

File tree

7 files changed

+130
-82
lines changed

7 files changed

+130
-82
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
### Added
55
- Allow for customizing the changelog introduction.
66
- Make `changelog.instance` property public.
7-
- Introduce changelog description and changelog section summary [#127](../../issues/127)
8-
- Introduce changelog description and changelog section summary [#127](../../issues/127)
7+
- Introduce changelog `description` and changelog section summary [#127](../../issues/127)
8+
- Introduce changelog `preTitle` and `title` changelog properties
99
- Ensure patched changelog ends with a newline [#126](../../issues/126)
1010

1111
### Changed

src/test/kotlin/org/jetbrains/changelog/BaseTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ open class BaseTest {
4545
field = value
4646
File("${project.projectDir}/build.gradle").run {
4747
createNewFile()
48-
writeText(value.trimIndent())
48+
writeText(value)
4949
}
5050
}
5151

src/test/kotlin/org/jetbrains/changelog/ChangelogPluginExtensionTest.kt

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
1010

1111
@BeforeTest
1212
fun localSetUp() {
13-
changelog =
13+
changelog = //language=markdown
1414
"""
1515
# Changelog
1616
Project description.
@@ -29,7 +29,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
2929
3030
### Removed
3131
- Bar
32-
"""
32+
""".trimIndent()
3333
}
3434

3535
@Test
@@ -52,6 +52,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
5252
extension.get(version).apply {
5353
assertEquals(project.version, version)
5454

55+
//language=markdown
5556
assertEquals(
5657
"""
5758
## [1.0.0]
@@ -64,6 +65,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
6465
toText()
6566
)
6667

68+
//language=markdown
6769
assertEquals(
6870
"""
6971
## [1.0.0]
@@ -76,6 +78,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
7678
toString()
7779
)
7880

81+
//language=markdown
7982
assertEquals(
8083
"""
8184
<h2>[1.0.0]</h2>
@@ -103,6 +106,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
103106
fun `getUnreleased() returns Unreleased section`() {
104107
extension.getUnreleased().apply {
105108
assertEquals("[Unreleased]", version)
109+
//language=markdown
106110
assertEquals(
107111
"""
108112
## [Unreleased]
@@ -123,6 +127,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
123127
extension.unreleasedTerm.set("[Upcoming]")
124128
extension.getUnreleased().withSummary(true).apply {
125129
assertEquals("[Upcoming]", version)
130+
//language=markdown
126131
assertEquals(
127132
"""
128133
## [Upcoming]
@@ -140,7 +145,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
140145
@Test
141146
@Suppress("LongMethod", "MaxLineLength")
142147
fun `parses changelog into structured sections`() {
143-
changelog =
148+
changelog = //language=markdown
144149
"""
145150
# Changelog
146151
My project description.
@@ -164,11 +169,12 @@ class ChangelogPluginExtensionTest : BaseTest() {
164169
165170
### Removed
166171
- Hola
167-
"""
172+
""".trimIndent()
168173

169174
extension.get(version).apply {
170175
assertEquals(this@ChangelogPluginExtensionTest.version, version)
171176
assertEquals("## [1.0.0]", header)
177+
//language=markdown
172178
assertEquals(
173179
"""
174180
First release.
@@ -187,6 +193,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
187193
assertTrue(containsKey("Removed"))
188194
assertEquals(1, get("Removed")?.size)
189195
}
196+
//language=markdown
190197
assertEquals(
191198
"""
192199
## [1.0.0]
@@ -212,6 +219,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
212219
""".trimIndent(),
213220
toText()
214221
)
222+
//language=html
215223
assertEquals(
216224
"""
217225
<h2>[1.0.0]</h2>
@@ -231,6 +239,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
231239
""".trimIndent(),
232240
toHTML()
233241
)
242+
//language=markdown
234243
assertEquals(
235244
"""
236245
[1.0.0]
@@ -261,7 +270,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
261270

262271
@Test
263272
fun `filters out entries from the change notes for the given version`() {
264-
changelog =
273+
changelog = //language=markdown
265274
"""
266275
# Changelog
267276
@@ -279,7 +288,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
279288
280289
### Removed
281290
- Hola x
282-
"""
291+
""".trimIndent()
283292

284293
extension.get(version).apply {
285294
assertEquals(this@ChangelogPluginExtensionTest.version, version)
@@ -297,6 +306,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
297306
assertFalse(containsKey("Removed"))
298307
}
299308

309+
//language=markdown
300310
assertEquals(
301311
"""
302312
## [1.0.0]
@@ -312,6 +322,8 @@ class ChangelogPluginExtensionTest : BaseTest() {
312322
""".trimIndent(),
313323
toText()
314324
)
325+
326+
//language=html
315327
assertEquals(
316328
"""
317329
<h2>[1.0.0]</h2>
@@ -334,10 +346,11 @@ class ChangelogPluginExtensionTest : BaseTest() {
334346
extension.getLatest().apply {
335347
assertEquals("[Unreleased]", version)
336348
assertEquals("## [Unreleased]", header)
349+
//language=markdown
337350
assertEquals(
338351
"""
339-
Not yet released version.
340-
352+
Not yet released version.
353+
341354
""".trimIndent(),
342355
summary,
343356
)
@@ -353,15 +366,15 @@ class ChangelogPluginExtensionTest : BaseTest() {
353366

354367
@Test
355368
fun `parses header with custom format containing version and date`() {
356-
changelog =
369+
changelog = //language=markdown
357370
"""
358371
# Changelog
359372
## NEW VERSION
360373
- Compatible with IDEA 2020.2 EAPs
361374
362375
## Version 1.0.1119-eap (29 May 2020)
363376
- Compatible with IDEA 2020.2 EAPs
364-
"""
377+
""".trimIndent()
365378

366379
extension.unreleasedTerm.set("NEW VERSION")
367380
extension.get("1.0.1119-eap").apply {
@@ -371,12 +384,12 @@ class ChangelogPluginExtensionTest : BaseTest() {
371384

372385
@Test
373386
fun `returns change notes without group sections if not present`() {
374-
changelog =
387+
changelog = //language=markdown
375388
"""
376389
# Changelog
377390
## [1.0.0]
378391
- Foo
379-
"""
392+
""".trimIndent()
380393

381394
extension.get("1.0.0").apply {
382395
assertEquals("1.0.0", version)
@@ -386,6 +399,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
386399
assertTrue(containsKey(""))
387400
assertEquals(1, get("")?.size)
388401
}
402+
//language=markdown
389403
assertEquals(
390404
"""
391405
## [1.0.0]
@@ -395,6 +409,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
395409
""".trimIndent(),
396410
toText()
397411
)
412+
//language=html
398413
assertEquals(
399414
"""
400415
<h2>[1.0.0]</h2>
@@ -409,20 +424,21 @@ class ChangelogPluginExtensionTest : BaseTest() {
409424

410425
@Test
411426
fun `splits change notes into a list by the given itemPrefix`() {
412-
changelog =
427+
changelog = //language=markdown
413428
"""
414429
# Changelog
415430
## [1.0.0]
416431
- Foo - bar
417432
* Foo2
418433
- Bar
419-
"""
434+
""".trimIndent()
420435

421436
extension.get("1.0.0").apply {
422437
assertEquals("1.0.0", version)
423438
assertEquals(1, getSections().keys.size)
424439
getSections().values.first().apply {
425440
assertEquals(2, size)
441+
//language=markdown
426442
assertEquals(
427443
"""
428444
- Foo - bar
@@ -444,6 +460,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
444460
assertEquals("1.0.0", keys.last())
445461
assertEquals("## [Unreleased]", values.first().header)
446462
assertEquals("## [1.0.0]", values.last().header)
463+
//language=markdown
447464
assertEquals(
448465
"""
449466
## [Unreleased]
@@ -455,6 +472,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
455472
""".trimIndent(),
456473
values.first().toText()
457474
)
475+
//language=markdown
458476
assertEquals(
459477
"""
460478
## [Unreleased]
@@ -466,6 +484,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
466484
""".trimIndent(),
467485
values.first().toText()
468486
)
487+
//language=markdown
469488
assertEquals(
470489
"""
471490
## [1.0.0]
@@ -477,6 +496,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
477496
""".trimIndent(),
478497
values.last().toText()
479498
)
499+
//language=markdown
480500
assertEquals(
481501
"""
482502
## [1.0.0]
@@ -495,7 +515,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
495515
fun `returns Changelog items for change note without category`() {
496516
extension.itemPrefix.set("*")
497517
extension.unreleasedTerm.set("Unreleased")
498-
changelog =
518+
changelog = //language=markdown
499519
"""
500520
# My Changelog
501521
@@ -506,6 +526,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
506526
""".trimIndent()
507527

508528
assertNotNull(extension.getLatest())
529+
//language=html
509530
assertEquals(
510531
"""
511532
<h2>Unreleased</h2>
@@ -519,14 +540,14 @@ class ChangelogPluginExtensionTest : BaseTest() {
519540

520541
@Test
521542
fun `allows to customize the header parser regex to match version in different format than semver`() {
522-
changelog =
543+
changelog = //language=markdown
523544
"""
524545
# My Changelog
525546
526547
## 2020.1
527548
528549
* Foo
529-
"""
550+
""".trimIndent()
530551

531552
extension.headerParserRegex.set("""\d+\.\d+""".toRegex())
532553
assertNotNull(extension.get("2020.1"))
@@ -545,28 +566,28 @@ class ChangelogPluginExtensionTest : BaseTest() {
545566

546567
@Test
547568
fun `return null for non-existent version`() {
548-
changelog =
569+
changelog = //language=markdown
549570
"""
550571
# My Changelog
551572
552573
## 1.0.0
553574
554575
* Foo
555-
"""
576+
""".trimIndent()
556577

557578
assertNull(extension.getOrNull("2.0.0"))
558579
}
559580

560581
@Test
561582
fun `return change notes for version with custom headerParserRegex`() {
562-
changelog =
583+
changelog = //language=markdown
563584
"""
564585
# My Changelog
565586
566587
## [v1.0.0]
567588
568589
* Foo
569-
"""
590+
""".trimIndent()
570591

571592
extension.headerParserRegex.set("\\[?v(\\d(?:\\.\\d+)+)]?.*".toRegex())
572593

@@ -576,7 +597,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
576597

577598
@Test
578599
fun `return change notes without summary`() {
579-
changelog =
600+
changelog = //language=markdown
580601
"""
581602
# My Changelog
582603
@@ -585,10 +606,11 @@ class ChangelogPluginExtensionTest : BaseTest() {
585606
586607
* Foo
587608
588-
"""
609+
""".trimIndent()
589610

590611
extension.get("1.0.0").apply {
591612
assertEquals("1.0.0", version)
613+
//language=markdown
592614
assertEquals(
593615
"""
594616
## [1.0.0]
@@ -604,6 +626,7 @@ class ChangelogPluginExtensionTest : BaseTest() {
604626

605627
@Test
606628
fun `returns changelog description`() {
629+
//language=markdown
607630
assertEquals(
608631
"""
609632
Project description.
@@ -623,5 +646,4 @@ class ChangelogPluginExtensionTest : BaseTest() {
623646

624647
assertEquals("New introduction", extension.instance.introductionValue)
625648
}
626-
627649
}

0 commit comments

Comments
 (0)