use crate::{
    codegen::SvgDocument,
    types::nodes::primitives::{
        component_transfer::{ComponentTransfer, TransferFn},
        FePrimitive,
    },
    Node,
};

#[test]
fn test_comp_trans_simple() {
    let mut doc = SvgDocument::new();

    let comptrans = doc.create_filter("comp_trans");

    comptrans.add_node(Node::simple(FePrimitive::ComponentTransfer(
        ComponentTransfer {
            func_r: TransferFn::Table {
                table_values: vec![0., 0.1, 0.4, 0.9],
            },
            func_g: TransferFn::Discrete {
                table_values: vec![0.1, 0.3, 0.5, 0.7, 0.9],
            },
            func_b: TransferFn::Linear {
                slope: 1.0,
                intercept: 0.75,
            },
            func_a: TransferFn::Identity,
        },
    )));

    assert_eq!(
        doc.generate_svg(),
        r#"<svg><filter id="comp_trans"><feComponentTransfer><feFuncR type="table" tableValues="0 0.1 0.4 0.9"/><feFuncG type="discrete" tableValues="0.1 0.3 0.5 0.7 0.9"/><feFuncB type="linear" slope="1" intercept="0.75"/><feFuncA type="identity"/></feComponentTransfer></filter></svg>"#
    );
}
