File size: 1,787 Bytes
52efc7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

import { describe, expect, it } from 'vitest';
import { detectOmissionPlaceholders } from './omissionPlaceholderDetector.js';

describe('detectOmissionPlaceholders', () => {
  it('detects standalone placeholder lines', () => {
    expect(detectOmissionPlaceholders('(rest of methods ...)')).toEqual([
      'rest of methods ...',
    ]);
    expect(detectOmissionPlaceholders('(rest of code ...)')).toEqual([
      'rest of code ...',
    ]);
    expect(detectOmissionPlaceholders('(unchanged code ...)')).toEqual([
      'unchanged code ...',
    ]);
    expect(detectOmissionPlaceholders('// rest of methods ...')).toEqual([
      'rest of methods ...',
    ]);
  });

  it('detects case-insensitive placeholders', () => {
    expect(detectOmissionPlaceholders('(Rest Of Methods ...)')).toEqual([
      'rest of methods ...',
    ]);
  });

  it('detects multiple placeholder lines in one input', () => {
    const text = `class Example {
  run() {}
  (rest of methods ...)
  (unchanged code ...)
}`;
    expect(detectOmissionPlaceholders(text)).toEqual([
      'rest of methods ...',
      'unchanged code ...',
    ]);
  });

  it('does not detect placeholders embedded in normal code', () => {
    expect(
      detectOmissionPlaceholders(
        'const note = "(rest of methods ...)";\nconsole.log(note);',
      ),
    ).toEqual([]);
  });

  it('does not detect omission phrase when inline in a comment', () => {
    expect(
      detectOmissionPlaceholders('return value; // rest of methods ...'),
    ).toEqual([]);
  });

  it('does not detect unrelated ellipsis text', () => {
    expect(detectOmissionPlaceholders('const message = "loading...";')).toEqual(
      [],
    );
  });
});