Skip to content

Commit 424a5bb

Browse files
myieyeclaude
andcommitted
Fix func-style lint warning in formatRelativeDate test
Convert the cfg helper from an arrow expression to a function declaration to match the project's ESLint config. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4dca64e commit 424a5bb

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
11
import {describe, expect, it} from 'vitest';
22
import {formatRelativeDate} from './format-relative-date-fn.svelte';
33

4-
const cfg = (now: Date, smallestUnit: 'milliseconds' | 'seconds' | 'minutes' | 'hours' = 'seconds') => ({
5-
defaultValue: 'NEVER',
6-
now,
7-
smallestUnit,
8-
});
4+
function config(now: Date, smallestUnit: 'milliseconds' | 'seconds' | 'minutes' | 'hours' = 'seconds') {
5+
return {defaultValue: 'NEVER', now, smallestUnit};
6+
}
97

108
describe('formatRelativeDate', () => {
119
it('returns defaultValue for nullish input', () => {
1210
const now = new Date();
13-
expect(formatRelativeDate(null, undefined, cfg(now))).toBe('NEVER');
14-
expect(formatRelativeDate(undefined, undefined, cfg(now))).toBe('NEVER');
11+
expect(formatRelativeDate(null, undefined, config(now))).toBe('NEVER');
12+
expect(formatRelativeDate(undefined, undefined, config(now))).toBe('NEVER');
1513
});
1614

1715
it('formats a past duration', () => {
1816
const now = new Date();
19-
const result = formatRelativeDate(new Date(now.getTime() - 3000), undefined, cfg(now));
17+
const result = formatRelativeDate(new Date(now.getTime() - 3000), undefined, config(now));
2018
expect(result.startsWith('3 ')).toBe(true);
2119
expect(result.endsWith(' ago')).toBe(true);
2220
});
2321

2422
it('formats a future duration', () => {
2523
const now = new Date();
26-
const result = formatRelativeDate(new Date(now.getTime() + 3000), undefined, cfg(now));
24+
const result = formatRelativeDate(new Date(now.getTime() + 3000), undefined, config(now));
2725
expect(result.startsWith('in 3 ')).toBe(true);
2826
});
2927

3028
it('falls back to a zero-duration string when diff is below smallestUnit', () => {
3129
const now = new Date();
32-
expect(formatRelativeDate(new Date(now.getTime() - 500), undefined, cfg(now))).toMatch(/^0 .+ ago$/);
33-
expect(formatRelativeDate(new Date(now.getTime() + 500), undefined, cfg(now))).toMatch(/^in 0 /);
30+
expect(formatRelativeDate(new Date(now.getTime() - 500), undefined, config(now))).toMatch(/^0 .+ ago$/);
31+
expect(formatRelativeDate(new Date(now.getTime() + 500), undefined, config(now))).toMatch(/^in 0 /);
3432
});
3533

3634
it('produces the correct plural for zero (style=long)', () => {
3735
const now = new Date();
38-
expect(formatRelativeDate(now, {style: 'long'}, cfg(now))).toContain('0 seconds');
36+
expect(formatRelativeDate(now, {style: 'long'}, config(now))).toContain('0 seconds');
3937
});
4038

4139
it('accepts ISO-string dates', () => {
4240
const now = new Date();
4341
const earlier = new Date(now.getTime() - 3000).toISOString();
44-
expect(formatRelativeDate(earlier, undefined, cfg(now)).startsWith('3 ')).toBe(true);
42+
expect(formatRelativeDate(earlier, undefined, config(now)).startsWith('3 ')).toBe(true);
4543
});
4644
});

0 commit comments

Comments
 (0)