Skip to content

Commit b8a500c

Browse files
committed
add more tests
1 parent 644c661 commit b8a500c

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

CLAUDE.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/detector.test.js

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ describe('containsJSX', () => {
115115
`;
116116
expect(containsJSX(source)).toBe(false);
117117
});
118+
119+
it('returns false for JSX-like comments', () => {
120+
const source = `
121+
// This comment mentions <div> but is not JSX
122+
/* <p>This is also not JSX</p> */
123+
function notJSX() {
124+
return "string with <tag>";
125+
}
126+
`;
127+
expect(containsJSX(source)).toBe(false);
128+
});
118129
});
119130

120131
describe('TypeScript generics (no false positives)', () => {
@@ -270,6 +281,33 @@ describe('containsJSX', () => {
270281
});
271282
});
272283

284+
describe('JSX syntax variants', () => {
285+
it('detects JSX with namespaced name', () => {
286+
const source = `const App = () => <xml:svg><xml:circle /></xml:svg>;`;
287+
expect(containsJSX(source)).toBe(true);
288+
});
289+
290+
it('detects JSX with member expression', () => {
291+
const source = `const App = () => <UI.Button onClick={handler} />;`;
292+
expect(containsJSX(source)).toBe(true);
293+
});
294+
295+
it('detects JSX with spread attribute', () => {
296+
const source = `const App = () => <Component {...props} />;`;
297+
expect(containsJSX(source)).toBe(true);
298+
});
299+
300+
it('detects JSX with spread child', () => {
301+
const source = `const App = () => <ul>{...items}</ul>;`;
302+
expect(containsJSX(source)).toBe(true);
303+
});
304+
305+
it('detects JSX attribute value as element', () => {
306+
const source = `const App = () => <Foo bar=<Bar /> />;`;
307+
expect(containsJSX(source)).toBe(true);
308+
});
309+
});
310+
273311
describe('Edge cases', () => {
274312
it('detects JSX in arrow functions', () => {
275313
const source = `
@@ -295,16 +333,5 @@ describe('containsJSX', () => {
295333
`;
296334
expect(containsJSX(source)).toBe(true);
297335
});
298-
299-
it('returns false for JSX-like comments', () => {
300-
const source = `
301-
// This comment mentions <div> but is not JSX
302-
/* <p>This is also not JSX</p> */
303-
function notJSX() {
304-
return "string with <tag>";
305-
}
306-
`;
307-
expect(containsJSX(source)).toBe(false);
308-
});
309336
});
310337
});

0 commit comments

Comments
 (0)