Add doc and tests

This commit is contained in:
Rémi BERTHO 2020-05-24 18:16:32 +02:00
parent 4bd5e1eb5e
commit 3ace078024
Signed by: dalan
GPG key ID: EE3B917931C07B64
4 changed files with 39 additions and 0 deletions

View file

@ -5,6 +5,7 @@ use url::Url;
use anyhow::{Result, anyhow};
#[derive(Debug)]
/// Parser for the darty website
pub struct Darty {
price_selector: Selector,
name_selector: Selector,
@ -46,4 +47,12 @@ impl PriceParser for Darty {
price
})
}
}
#[test]
fn test_parser_darty() {
let darty_parser = Darty::new().unwrap();
assert!(darty_parser.can_parse(&Url::parse("https://www.darty.com/nav/achat/gros_electromenager/refrigerateur-congelateur-refrigerateur-cong/refrigerateur-congelateur_bas/samsung_rb33n300nsa_ef.html").unwrap()));
assert!(darty_parser.can_parse(&Url::parse("http://www.darty.com/nav/achat/gros_electromenager/refrigerateur-congelateur-refrigerateur-cong/refrigerateur-congelateur_bas/samsung_rb33n300nsa_ef.html").unwrap()));
assert!(darty_parser.can_parse(&Url::parse("https://www.fnace.com").unwrap()) == false);
}