1
//! Tests for the account pick to commodity fill rule.
2

            
3
use super::super::{commodity_fill, parse_form_options};
4

            
5
const REPLY: &str = r#"(:id 1 :value "((:id \"a-one\" :label \"One\" :commodity \"u-usd\") (:id \"a-many\" :label \"Many\"))")"#;
6

            
7
#[test]
8
1
fn an_account_with_one_commodity_fills_it() {
9
1
    let options = parse_form_options(REPLY);
10
1
    assert_eq!(commodity_fill(&options, "a-one"), Some("u-usd".to_string()));
11
1
}
12

            
13
#[test]
14
1
fn an_account_with_several_commodities_fills_nothing() {
15
1
    let options = parse_form_options(REPLY);
16
1
    assert_eq!(commodity_fill(&options, "a-many"), None);
17
1
}
18

            
19
#[test]
20
1
fn an_unknown_account_fills_nothing() {
21
1
    let options = parse_form_options(REPLY);
22
1
    assert_eq!(commodity_fill(&options, ""), None);
23
1
    assert_eq!(commodity_fill(&options, "a-none"), None);
24
1
}