Skip to content

Commit 341e411

Browse files
committed
fix: update Christmas date to 2030 and improve regex for days validation in calculator tests
1 parent df99366 commit 341e411

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

wox.core/test/converter_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package test
22

33
import (
44
"fmt"
5+
"regexp"
56
"strings"
67
"testing"
78
"time"
@@ -188,10 +189,11 @@ func TestCalculatorTime(t *testing.T) {
188189
}
189190
expectedMonday := fmt.Sprintf("%s (Monday)", targetDate.Format("2006-01-02"))
190191

191-
// Calculate expected days until Christmas 2025
192-
christmas := time.Date(2025, time.December, 25, 0, 0, 0, 0, time.Local)
192+
// Calculate expected days until Christmas 2030
193+
christmas := time.Date(2030, time.December, 25, 0, 0, 0, 0, time.Local)
193194
daysUntilChristmas := int(christmas.Sub(now).Hours() / 24)
194195
expectedDaysUntil := fmt.Sprintf("%d days", daysUntilChristmas)
196+
daysUntilRe := regexp.MustCompile(`^\d+ days$`)
195197

196198
tests := []QueryTest{
197199
{
@@ -216,12 +218,11 @@ func TestCalculatorTime(t *testing.T) {
216218
},
217219
{
218220
Name: "Days until Christmas",
219-
Query: "days until 25 Dec 2025",
221+
Query: "days until 25 Dec 2030",
220222
ExpectedTitle: expectedDaysUntil,
221223
ExpectedAction: "Copy",
222224
TitleCheck: func(title string) bool {
223-
// Should contain "days"
224-
return strings.Contains(title, "days")
225+
return daysUntilRe.MatchString(title)
225226
},
226227
},
227228
{
@@ -303,11 +304,11 @@ func TestCalculatorTime(t *testing.T) {
303304
},
304305
{
305306
Name: "Days until specific date",
306-
Query: "days until 25th Dec 2024",
307+
Query: "days until 25th Dec 2030",
307308
ExpectedTitle: "",
308309
ExpectedAction: "Copy",
309310
TitleCheck: func(title string) bool {
310-
return strings.Contains(title, "days")
311+
return daysUntilRe.MatchString(title)
311312
},
312313
},
313314
}

0 commit comments

Comments
 (0)