Skip to content

Commit de565b0

Browse files
committed
format
1 parent eaa1c93 commit de565b0

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

__tests__/MetaDescription_.test.res

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
open Vitest
22

33
test("returns the first sentence for a one-sentence description", async () => {
4-
let result = MetaDescription.shortenForSocialPreview(
5-
"JavaScript Made Simple for Humans and AI.",
6-
)
4+
let result = MetaDescription.shortenForSocialPreview("JavaScript Made Simple for Humans and AI.")
75

86
expect(result)->toBe("JavaScript Made Simple for Humans and AI.")
97
})
@@ -28,13 +26,16 @@ test("returns only the first sentence when the first sentence exceeds 140 charac
2826
)
2927
})
3028

31-
test("returns only the first sentence when the second sentence exceeds 140 characters", async () => {
32-
let result = MetaDescription.shortenForSocialPreview(
33-
"Short opening sentence. This second sentence is intentionally long enough to cross the one hundred and forty character threshold before it reaches its final word in the sentence.",
34-
)
29+
test(
30+
"returns only the first sentence when the second sentence exceeds 140 characters",
31+
async () => {
32+
let result = MetaDescription.shortenForSocialPreview(
33+
"Short opening sentence. This second sentence is intentionally long enough to cross the one hundred and forty character threshold before it reaches its final word in the sentence.",
34+
)
3535

36-
expect(result)->toBe("Short opening sentence.")
37-
})
36+
expect(result)->toBe("Short opening sentence.")
37+
},
38+
)
3839

3940
test("collapses line breaks and repeated spaces before evaluating the sentences", async () => {
4041
let result = MetaDescription.shortenForSocialPreview(

docs/superpowers/plans/2026-04-24-meta-description-shortening.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### Task 1: Create the utility and prove the base behavior with a failing test
1414

1515
**Files:**
16+
1617
- Create: `src/common/MetaDescription.res`
1718
- Test: `__tests__/MetaDescription_.test.res`
1819

@@ -75,6 +76,7 @@ git commit -m "feat: add meta description utility"
7576
### Task 2: Extend the tests and utility to cover sentence-length and whitespace rules
7677

7778
**Files:**
79+
7880
- Modify: `src/common/MetaDescription.res`
7981
- Modify: `__tests__/MetaDescription_.test.res`
8082

@@ -187,6 +189,7 @@ git commit -m "test: cover meta description shortening rules"
187189
### Task 3: Replace the inline `Meta` helper with the shared utility
188190

189191
**Files:**
192+
190193
- Modify: `src/components/Meta.res`
191194
- Test: `__tests__/MetaDescription_.test.res`
192195

src/common/MetaDescription.res

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ let ensurePeriod = sentence =>
1111

1212
let shortenForSocialPreview = description => {
1313
let normalized = collapseWhitespace(description)
14-
let sentences = normalized->String.split(".")->Array.map(String.trim)->Array.filter(sentence => sentence != "")
14+
let sentences =
15+
normalized->String.split(".")->Array.map(String.trim)->Array.filter(sentence => sentence != "")
1516

1617
switch (sentences->Array.get(0), sentences->Array.get(1)) {
1718
| (Some(firstSentence), Some(secondSentence))

0 commit comments

Comments
 (0)