RocketChat / RocketChat/Rocket.Chat

`timestamp.test.ts` defines shared helper functions inline instead of importing from `helpers.ts`

Open
#39,683 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
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 in timestamp.test.ts could silently drift out of sync
  • The fix is purely a code cleanup with no behavior change

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.