Skip to content

Commit 046e6d2

Browse files
authored
merge: test: add type compiler tests for CodeBlock (#8120)
## Description Fixes #6907 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview N/A ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [ ] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [ ] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 4a88902 + 7d81799 commit 046e6d2

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { describe, expectTypeOf, it } from 'vitest';
2+
import React from 'react';
3+
import { CodeBlock } from './code-block';
4+
5+
type CodeBlockProps = React.ComponentProps<typeof CodeBlock>;
6+
7+
describe('CodeBlock Type Compiler Validation', () => {
8+
it('maintains expected props structure', () => {
9+
expectTypeOf<CodeBlockProps>().toEqualTypeOf<{
10+
code: string;
11+
}>();
12+
});
13+
14+
it('accepts valid prop values', () => {
15+
const props: CodeBlockProps = {
16+
code: 'console.log("Hello");',
17+
};
18+
19+
expectTypeOf(props).toEqualTypeOf<CodeBlockProps>();
20+
});
21+
22+
it('rejects invalid code prop type', () => {
23+
const invalid: CodeBlockProps = {
24+
// @ts-expect-error code must be a string
25+
code: 123,
26+
};
27+
28+
void invalid;
29+
});
30+
31+
it('returns a valid React element', () => {
32+
const element = <CodeBlock code="const a = 1;" />;
33+
34+
expectTypeOf(element).toMatchTypeOf<React.ReactElement>();
35+
});
36+
37+
it('enforces strict property configuration', () => {
38+
expectTypeOf<keyof CodeBlockProps>().toEqualTypeOf<'code'>();
39+
});
40+
});

0 commit comments

Comments
Β (0)