Skip to content

Commit

Permalink
โœ… update tests for day that were using system local time
Browse files Browse the repository at this point in the history
the recently added test were bound to fail as the day changed
  • Loading branch information
ttytm committed Oct 14, 2024
1 parent fd2e3c6 commit 0245c7d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/modules/display/day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,41 +143,48 @@ mod tests {
use crate::modules::display::utils::common_tests::{
init_test_params, init_test_product, TEST_PARAMS, TEST_PRODUCT,
};
use chrono::{Datelike, Weekday};
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);

// TODO: store parsed date as params value to reduce redudancy.
let test_date =
NaiveDate::parse_from_str(&test_product.weather.current_weather.time, "%Y-%m-%dT%H:%M").unwrap();
assert_eq!(test_date.weekday(), Weekday::Mon);

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 โ”‚
โ”‚ ๎Œ› Slight Rain Showers, 15.1/6.8ยฐC โฒ25๓ฐ–Žโณ ๎ชฐ Mon, 7 Oct โ”‚
โ”‚ Feels like 14.5/4.3ยฐC ๎Œ 07:18 ๎ƒ 18:29 โ”‚
โ”‚ โ”‚
โ”‚ Hourly Forecast โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚ โ‚โ‚ƒ๎Œ’ โ‚โ‚‚๎Œ’ โ‚โ‚‚๎Œถ โ‚โ‚ƒ๎Œ’ โ‚โ‚ˆ๎Œ‚ โ‚‚โ‚€๎Œ’ โ‚โ‚‰๎Œ’ โ‚โ‚‡๎Œ’ ๎Œน โ”‚
โ”‚ 15.1/6.8ยฐC โฒ25๓ฐ–Žโณ โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ•คโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚ โ‚‰๎ป โ‚ˆ๎ป โ‚‡๎Œฎ โ‚‡๎Œ‚ โ‚โ‚‚๎Œ’ โ‚โ‚…๎Œ’ โ‚โ‚„๎Œ’ โ‚โ‚„๎Œ’ ๎Œน โ”‚
โ”‚ โ”‚
โ”‚ ๐Ÿญบ๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญท๐Ÿญถ๐Ÿญถ๐Ÿญถโ–”โ–”โ–”โ–”โ–”โ–”โ–”๐Ÿญถ๐Ÿญถ๐Ÿญถ๐Ÿญท๐Ÿญท๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญป๐Ÿญป๐Ÿญปโ–โ–โ– โ”‚
โ”‚๐Ÿญป๐Ÿญป๐Ÿญปโ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–๐Ÿญป๐Ÿญป๐Ÿญป๐Ÿญบ๐Ÿญน๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญท๐Ÿญถโ–”โ–”โ–” โ–”โ–”โ–”โ”‚
โ”‚ โ‚€ โ‚‚โ‚€ โ‚ˆโ‚ˆ โ‚โ‚ƒ โ‚ƒ โ‚€ โ‚โ‚ƒ โ‚‡โ‚€ ๓ฐ–Ž โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚ ๐Ÿญบ๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญท๐Ÿญถ๐Ÿญถ๐Ÿญถโ–”โ–”โ–”โ–”๐Ÿญถ๐Ÿญถ๐Ÿญถ๐Ÿญถ๐Ÿญถ๐Ÿญถ๐Ÿญท๐Ÿญท๐Ÿญท๐Ÿญท๐Ÿญท๐Ÿญท๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญธ๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญนโ”‚
โ”‚๐Ÿญน๐Ÿญน๐Ÿญน๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญบ๐Ÿญป๐Ÿญป๐Ÿญป๐Ÿญป๐Ÿญป๐Ÿญปโ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–๐Ÿญป๐Ÿญป๐Ÿญบ๐Ÿญน๐Ÿญธ๐Ÿญท๐Ÿญถโ–”โ–” โ”‚
โ”‚ โ‚€ โ‚€ โ‚€ โ‚€ โ‚€ โ‚‚โ‚… โ‚€ โ‚€ ๓ฐ–Ž โ”‚
โ”œโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ•งโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ค
โ”‚โฐโฐห™โฐโฐ โฐยณห™โฐโฐ โฐโถห™โฐโฐ โฐโนห™โฐโฐ ยนยฒห™โฐโฐ ยนโตห™โฐโฐ ยนโธห™โฐโฐ ยฒยนห™โฐโฐ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ";

// FIXME: index
let lines = prep(test_product, test_params, 1).unwrap();
let lines = prep(test_product, test_params, 0).unwrap();
let have = strip_ansi_escapes::strip_str(lines.join("\n"));
println!("{have}");
assert_eq!(want, have);

let want = "\
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Berlin, Germany โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ๎Œ› Moderate Rain, 17.9/13.7ยฐC โฒ98๓ฐ–Žโณ ๎ชฐ Tue, 15 Oct โ”‚
โ”‚ ๎Œ› Moderate Rain, 17.9/13.7ยฐC โฒ98๓ฐ–Žโณ ๎ชฐ Wed, 9 Oct โ”‚
โ”‚ Feels like 17.4/13.7ยฐC ๎Œ 07:22 ๎ƒ 18:24 โ”‚
โ”‚ โ”‚
โ”‚ Hourly Forecast โ”‚
Expand Down

0 comments on commit 0245c7d

Please sign in to comment.