Skip to content

Commit 561fed7

Browse files
JohnMcLearclaude
andcommitted
test: fix regex that couldn't match setInterval with arrow-fn nested parens
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fa8a380 commit 561fed7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

static/tests/backend/specs/relative_time.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ describe(__filename, function () {
1515

1616
it('registers a setInterval that calls refreshRelativeDates (#154)', function () {
1717
// Any cadence works, but the interval must actually be scheduled so the
18-
// relative-time strings update without a page reload.
19-
assert(/setInterval\([^)]*refreshRelativeDates[^)]*\)/.test(src),
20-
'init should call setInterval(() => this.refreshRelativeDates(), ...)');
18+
// relative-time strings update without a page reload. A one-line regex
19+
// can't reliably parse nested parens (`setInterval(() => ...)`), so
20+
// just require the two identifiers to live in the same statement.
21+
const stmt = src.match(/setInterval[\s\S]*?refreshRelativeDates[\s\S]*?\);/);
22+
assert(stmt, 'init should schedule setInterval(() => this.refreshRelativeDates(), ...)');
2123
});
2224

2325
it('refreshRelativeDates recomputes text from the datetime attribute (#154)',

0 commit comments

Comments
 (0)