1+ import { detectCodeOmission } from '../detect-omission'
2+
3+ describe ( 'detectCodeOmission' , ( ) => {
4+ const originalContent = `function example() {
5+ // Some code
6+ const x = 1;
7+ const y = 2;
8+ return x + y;
9+ }`
10+
11+ it ( 'should detect square bracket line range omission' , ( ) => {
12+ const newContent = `[Previous content from line 1-305 remains exactly the same]
13+ const z = 3;`
14+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( true )
15+ } )
16+
17+ it ( 'should detect single-line comment omission' , ( ) => {
18+ const newContent = `// Lines 1-50 remain unchanged
19+ const z = 3;`
20+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( true )
21+ } )
22+
23+ it ( 'should detect multi-line comment omission' , ( ) => {
24+ const newContent = `/* Previous content remains the same */
25+ const z = 3;`
26+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( true )
27+ } )
28+
29+ it ( 'should detect HTML-style comment omission' , ( ) => {
30+ const newContent = `<!-- Existing content unchanged -->
31+ const z = 3;`
32+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( true )
33+ } )
34+
35+ it ( 'should detect JSX-style comment omission' , ( ) => {
36+ const newContent = `{/* Rest of the code remains the same */}
37+ const z = 3;`
38+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( true )
39+ } )
40+
41+ it ( 'should detect Python-style comment omission' , ( ) => {
42+ const newContent = `# Previous content remains unchanged
43+ const z = 3;`
44+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( true )
45+ } )
46+
47+ it ( 'should not detect regular comments without omission keywords' , ( ) => {
48+ const newContent = `// Adding new functionality
49+ const z = 3;`
50+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( false )
51+ } )
52+
53+ it ( 'should not detect when comment is part of original content' , ( ) => {
54+ const originalWithComment = `// Content remains unchanged
55+ ${ originalContent } `
56+ const newContent = `// Content remains unchanged
57+ const z = 3;`
58+ expect ( detectCodeOmission ( originalWithComment , newContent ) ) . toBe ( false )
59+ } )
60+
61+ it ( 'should not detect code that happens to contain omission keywords' , ( ) => {
62+ const newContent = `const remains = 'some value';
63+ const unchanged = true;`
64+ expect ( detectCodeOmission ( originalContent , newContent ) ) . toBe ( false )
65+ } )
66+ } )
0 commit comments