euv-cli 0.28.3

The official CLI tool for the euv UI framework, providing dev/release profiles with run/build modes, hot reload, and wasm-pack integration.
Documentation
use super::*;

#[test]
fn extract_import_spec_strips_quotes_and_semicolon() {
    let rest: &str = "{ euv_event_collect_id_chain } from './snippets/euv-core-abc/inline1.js';";
    assert_eq!(
        extract_import_spec(rest),
        Some("./snippets/euv-core-abc/inline1.js")
    );
}

#[test]
fn extract_import_spec_handles_double_quotes() {
    let rest: &str = "* as import1 from \"./snippets/euv-core-abc/inline0.js\"";
    assert_eq!(
        extract_import_spec(rest),
        Some("./snippets/euv-core-abc/inline0.js")
    );
}

#[test]
fn extract_import_spec_rejects_non_relative_specs() {
    let rest: &str = "default from 'lodash';";
    assert_eq!(extract_import_spec(rest), None);
}

#[test]
fn is_namespace_import_detects_star_as() {
    assert!(is_namespace_import("* as import1 from './snippets/x.js';"));
    assert!(is_namespace_import("* as foo from \"./x.js\""));
    assert!(!is_namespace_import("{ a, b } from './snippets/x.js';"));
    assert!(!is_namespace_import("default from './x.js';"));
}

#[test]
fn extract_namespace_alias_returns_alias_name() {
    assert_eq!(
        extract_namespace_alias("* as import1 from \"./snippets/x.js\";"),
        Some("import1")
    );
    assert_eq!(
        extract_namespace_alias("* as foo from './x.js'"),
        Some("foo")
    );
    assert_eq!(extract_namespace_alias("{ a } from './x.js';"), None);
}

#[test]
fn extract_exported_function_names_finds_all_declarations() {
    let source: &str = r#"
export function euv_collect_subtree_ids(root) {
    return [];
}

export function euv_event_collect_id_chain(event, max_depth) {
    return ids;
}

function _private_helper() {}

// Re-exports / non-function exports are ignored.
export const VERSION = 1;
export { something };
"#;
    let names: Vec<String> = extract_exported_function_names(source);
    assert_eq!(
        names,
        vec![
            "euv_collect_subtree_ids".to_string(),
            "euv_event_collect_id_chain".to_string()
        ]
    );
}

#[test]
fn extract_exported_function_names_handles_empty_input() {
    let names: Vec<String> = extract_exported_function_names("");
    assert!(names.is_empty());
}

#[test]
fn extract_exported_function_names_supports_dollar_identifiers() {
    let source: &str = "export function foo$bar() {}\n";
    let names: Vec<String> = extract_exported_function_names(source);
    assert_eq!(names, vec!["foo$bar".to_string()]);
}