Add doc and tests
This commit is contained in:
parent
4bd5e1eb5e
commit
3ace078024
4 changed files with 39 additions and 0 deletions
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue