1
//! The convert form's commodity selects are filled from `form-options`.
2

            
3
use crate::form::Form;
4
use crate::modal::Modal;
5
use crate::route::{FormOptionsSource, Route, RouteCtx};
6
use crate::view::ViewId;
7

            
8
const USD: &str = "550e8400-e29b-41d4-a716-446655440001";
9

            
10
#[test]
11
1
fn commodity_options_fill_both_convert_selects() {
12
1
    let mut app = crate::test_support::app();
13
1
    app.overlays.push(Modal::Form(Form::commodity_convert()));
14
1
    app.form_options_seq.advance();
15
1
    let wire = format!(r#"(:id 9 :value "((:id \"{USD}\" :label \"USD\" :alias \"usd\"))")"#);
16
1
    app.deliver_reply(
17
1
        Route {
18
1
            target: Some(app.window_of(ViewId::Commodities)),
19
1
            ctx: RouteCtx::FormOptions {
20
1
                seq: 1,
21
1
                source: FormOptionsSource::FormCommodities,
22
1
            },
23
1
        },
24
1
        &wire,
25
1
    );
26
1
    let Some(Modal::Form(form)) = app.overlays.top() else {
27
        panic!("form open");
28
    };
29
1
    let values = form.values();
30
1
    assert_eq!(values.text("from"), Some(USD));
31
1
    assert_eq!(values.text("to"), Some(USD));
32
1
}