gobby-code 1.3.2

Fast Rust CLI for Gobby's code index — AST-aware search, symbol navigation, and dependency graph
Documentation
use super::*;

#[test]
fn skips_js_family_files_with_generated_markers() {
    let tmp = tempfile::tempdir().expect("tempdir");
    let root = tmp.path();
    let excludes: Vec<&str> = Vec::new();

    for (rel, marker) in [
        ("src/setup.mjs", "Generated by gcode setup"),
        ("src/app.js", "DO NOT EDIT"),
        ("src/view.jsx", "@generated"),
        ("src/runtime.cjs", "auto-generated"),
    ] {
        write_file(
            root,
            rel,
            format!("// {marker}\nexport const value = 1;\n").as_bytes(),
        );
        assert_eq!(classify_file(root, &root.join(rel), &excludes), None);
    }
}

#[test]
fn keeps_ordinary_mjs_source_ast_indexable() {
    let tmp = tempfile::tempdir().expect("tempdir");
    let root = tmp.path();
    write_file(
        root,
        "src/config.mjs",
        b"export function loadConfig() {\n  return { mode: 'dev' };\n}\n",
    );
    let excludes: Vec<&str> = Vec::new();

    assert_eq!(
        classify_file(root, &root.join("src/config.mjs"), &excludes),
        Some(FileClassification::Ast)
    );
}

#[test]
fn skips_large_minified_js_bundles() {
    let tmp = tempfile::tempdir().expect("tempdir");
    let root = tmp.path();
    let mut bundle = b"var bundle='".to_vec();
    bundle.extend(std::iter::repeat_n(b'a', MINIFIED_JS_MIN_BYTES));
    bundle.extend(b"';\n");
    write_file(root, "src/bundle.js", &bundle);
    let excludes: Vec<&str> = Vec::new();

    assert_eq!(
        classify_file(root, &root.join("src/bundle.js"), &excludes),
        None
    );
}

#[test]
fn skips_single_line_minified_js_bundle_with_newline() {
    let tmp = tempfile::tempdir().expect("tempdir");
    let root = tmp.path();
    let mut bundle = b"(()=>{const bundle='".to_vec();
    bundle.extend(std::iter::repeat_n(b'a', MINIFIED_JS_MIN_BYTES));
    bundle.extend(b"';})();\n");
    write_file(root, "dist/app.js", &bundle);
    let excludes: Vec<&str> = Vec::new();

    assert_eq!(
        classify_file(root, &root.join("dist/app.js"), &excludes),
        None
    );
}

#[test]
fn skips_single_line_minified_js_bundle_without_newline() {
    let tmp = tempfile::tempdir().expect("tempdir");
    let root = tmp.path();
    let mut bundle = b"(()=>{const bundle='".to_vec();
    bundle.extend(std::iter::repeat_n(b'a', MINIFIED_JS_MIN_BYTES));
    bundle.extend(b"';})();");
    write_file(root, "dist/app.js", &bundle);
    let excludes: Vec<&str> = Vec::new();

    assert_eq!(
        classify_file(root, &root.join("dist/app.js"), &excludes),
        None
    );
}