RocketChat / RocketChat/Rocket.Chat
`timestamp.test.ts` defines shared helper functions inline instead of importing from `helpers.ts`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
In timestamp.test.ts, common helper functions plain, paragraph, bold, and strike are defined inline instead of being imported from the shared helpers.ts file used by all other test files in the same directory.
Expected Behavior
timestamp.test.ts should import plain, paragraph, bold, and strike from helpers.ts, consistent with every other test file in the package.
Current Behavior
// these are defined inline in timestamp.test.ts
const plain = (value: string) => ({ type: 'PLAIN_TEXT' as const, value });
const paragraph = (value: Array<Record<string, unknown>>) => ({ type: 'PARAGRAPH' as const, value });
const bold = (value: Array<Record<string, unknown>>) => ({ type: 'BOLD' as const, value });
const strike = (value: Array<Record<string, unknown>>) => ({ type: 'STRIKE' as const, value });
Steps to Reproduce
See packages/message-parser/tests/timestamp.test.ts
Additional Context
- Every other test file in the package imports these helpers from helpers.ts
- If the shape of a node changes in
helpers.ts, the inline definitions intimestamp.test.tscould silently drift out of sync - The fix is purely a code cleanup with no behavior change
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open packages/message-parser/tests/timestamp.test.ts and compare its helper usage with helpers.ts and the other test files in the same directory. Replace the inline plain, paragraph, bold, and strike definitions with imports from helpers.ts, then verify the timestamp tests still pass with no behavior changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100