Skip to content

Commit

Permalink
โœ… add tests for day display module
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Oct 13, 2024
1 parent 1f2ae4f commit ef2b457
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/modules/display/day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,62 @@ pub fn prep(product: &Product, params: &Params, day_index: usize) -> Result<Vec<

Ok(result)
}

#[cfg(test)]
mod tests {
use super::*;
use crate::modules::display::utils::common_tests::{
init_test_params, init_test_product, TEST_PARAMS, TEST_PRODUCT,
};
use strip_ansi_escapes;

#[test]
fn output() {
let test_product = TEST_PRODUCT.get_or_init(|| init_test_product());
let test_params = TEST_PARAMS.get_or_init(|| init_test_params());

let want = "\
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Berlin, Germany โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ๎Œ› Slight Rain, 20.3/12.0ยฐC โฒ88๓ฐ–Žโณ ๎ชฐ Mon, 14 Oct โ”‚
โ”‚ Feels like 21.1/11.4ยฐC ๎Œ 07:20 ๎ƒ 18:26 โ”‚
โ”‚ โ”‚
โ”‚ Hourly Forecast โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚ โ‚โ‚ƒ๎Œ’ โ‚โ‚‚๎Œ’ โ‚โ‚‚๎Œถ โ‚โ‚ƒ๎Œ’ โ‚โ‚ˆ๎Œ‚ โ‚‚โ‚€๎Œ’ โ‚โ‚‰๎Œ’ โ‚โ‚‡๎Œ’ ๎Œน โ”‚
โ”‚ โ”‚
โ”‚ ๐Ÿญบ๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญท๐Ÿญถ๐Ÿญถ๐Ÿญถโ–”โ–”โ–”โ–”โ–”โ–”โ–”๐Ÿญถ๐Ÿญถ๐Ÿญถ๐Ÿญท๐Ÿญท๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญป๐Ÿญป๐Ÿญปโ–โ–โ– โ”‚
โ”‚๐Ÿญป๐Ÿญป๐Ÿญปโ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–๐Ÿญป๐Ÿญป๐Ÿญป๐Ÿญบ๐Ÿญน๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญท๐Ÿญถโ–”โ–”โ–” โ–”โ–”โ–”โ”‚
โ”‚ โ‚€ โ‚‚โ‚€ โ‚ˆโ‚ˆ โ‚โ‚ƒ โ‚ƒ โ‚€ โ‚โ‚ƒ โ‚‡โ‚€ ๓ฐ–Ž โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚โฐโฐห™โฐโฐ โฐยณห™โฐโฐ โฐโถห™โฐโฐ โฐโนห™โฐโฐ ยนยฒห™โฐโฐ ยนโตห™โฐโฐ ยนโธห™โฐโฐ ยฒยนห™โฐโฐ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ";

let lines = prep(test_product, test_params, 1).unwrap();
let have = strip_ansi_escapes::strip_str(lines.join("\n"));
assert_eq!(want, have);

let want = "\
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Berlin, Germany โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ๎Œ› Moderate Rain, 17.9/13.7ยฐC โฒ98๓ฐ–Žโณ ๎ชฐ Tue, 15 Oct โ”‚
โ”‚ Feels like 17.4/13.7ยฐC ๎Œ 07:22 ๎ƒ 18:24 โ”‚
โ”‚ โ”‚
โ”‚ Hourly Forecast โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚ โ‚โ‚†๎Œถ โ‚โ‚…๎Œด โ‚โ‚„๎Œถ โ‚โ‚„๎Œ’ โ‚โ‚‡๎ŒŒ โ‚โ‚‡๎Œ’ โ‚โ‚†๎Œ’ โ‚โ‚…๎Œถ ๎Œน โ”‚
โ”‚ โ”‚
โ”‚ ๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญธ๐Ÿญถ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญบ๐Ÿญบ๐Ÿญป๐Ÿญป๐Ÿญป๐Ÿญปโ– โ”‚
โ”‚โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”๐Ÿญท๐Ÿญธ๐Ÿญน๐Ÿญน๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญป๐Ÿญป๐Ÿญปโ–โ–โ–โ–โ–โ–๐Ÿญป๐Ÿญป๐Ÿญบ๐Ÿญน๐Ÿญน๐Ÿญธ๐Ÿญถโ–”โ–” โ–”โ–”โ–”๐Ÿญถ๐Ÿญถ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบโ”‚
โ”‚ โ‚ˆโ‚ƒ โ‚‰โ‚ˆ โ‚†โ‚ˆ โ‚ƒโ‚€ โ‚โ‚‡ โ‚โ‚‰ โ‚‚โ‚‡ โ‚‚โ‚‚ ๓ฐ–Ž โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚โฐโฐห™โฐโฐ โฐยณห™โฐโฐ โฐโถห™โฐโฐ โฐโนห™โฐโฐ ยนยฒห™โฐโฐ ยนโตห™โฐโฐ ยนโธห™โฐโฐ ยฒยนห™โฐโฐ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ";

let lines = prep(test_product, test_params, 2).unwrap();
let have = strip_ansi_escapes::strip_str(lines.join("\n"));
assert_eq!(want, have);
}
}

0 comments on commit ef2b457

Please sign in to comment.