forge
Explore
Log in

Don't you dare go Hollow

Fold the colour tests into fewer, broader ones

Browse files at this commit

3f07a50ccd8e5d98a6abf6b5a913f35fbb574c3fAhmet Kaan GümüşParent: 3637bc9
  • test
    • fold the colour tests into fewer, broader ones
Show full message
✅ test: fold the colour tests into fewer, broader ones
crates/forge-web/src/accent.rsmodified+1 -5
@@ -292,7 +292,7 @@ mod tests {
292292 }
293293
294294 #[test]
295- fn the_presets_are_offered_in_picker_order() {
295+ fn the_presets_are_offered_in_picker_order_and_removed_ids_are_not() {
296296 assert_eq!(
297297 ids().collect::<Vec<_>>(),
298298 ["sage", "spark", "ocean", "plum", "rose", "gold"]
@@ -301,10 +301,6 @@ mod tests {
301301 base_ids().collect::<Vec<_>>(),
302302 ["fern", "spark", "graphite", "dusk", "ink"]
303303 );
304- }
305-
306- #[test]
307- fn removed_ids_are_not_offered() {
308304 for id in ["ember", "ochre", "teal", "Sage", "sage ", "terracotta"] {
309305 assert!(!is_offered(id), "{id}");
310306 }
crates/forge-web/src/custom_colour.rsmodified+2 -10
@@ -344,20 +344,16 @@ mod tests {
344344 }
345345
346346 #[test]
347- fn the_extremes_are_exact() {
347+ fn the_extremes_are_exact_and_a_preset_hue_reads_back() {
348348 assert_eq!(colour(1.0, 0.0, 0.0), "#FFFFFF");
349349 assert_eq!(colour(0.0, 0.0, 0.0), "#000000");
350- }
351-
352- #[test]
353- fn a_preset_hue_reads_back_from_its_colour() {
354350 // Sage is about 149 degrees; Ocean about 240.
355351 assert_eq!(hex_hue("#5E7D63"), 149);
356352 assert_eq!(hex_hue("#467799"), 240);
357353 }
358354
359355 #[test]
360- fn every_hue_gives_hex_colours_with_the_right_token_names() {
356+ fn every_hue_gives_hex_colours_with_the_right_token_names_and_keyed_rules() {
361357 for hue in 0..360 {
362358 for dark in [false, true] {
363359 let accent = accent_tokens(hue, dark);
@@ -376,10 +372,6 @@ mod tests {
376372 }
377373 }
378374 }
379- }
380-
381- #[test]
382- fn the_stylesheet_keys_each_rule_on_its_hue() {
383375 let css = stylesheet(Some(215), Some(215), None, Some(7));
384376 assert!(
385377 css.contains(":root[data-accent-light=\"hue-215\"] {\n --accent: #"),
crates/forge-web/src/pages/assets.rsmodified+1 -5
@@ -434,7 +434,7 @@ mod tests {
434434 }
435435
436436 #[tokio::test]
437- async fn custom_css_keys_the_hue_choices_and_ignores_the_rest() {
437+ async fn custom_css_keys_the_hue_choices_and_is_empty_without_one() {
438438 let router: Router = Router::builder().discover().cookies().build();
439439 let req = Request::builder()
440440 .method("GET")
@@ -459,11 +459,7 @@ mod tests {
459459 assert!(css.contains(":root[data-base-light=\"hue-7\"] {"), "{css}");
460460 assert!(!css.contains("plum"), "{css}");
461461 assert!(!css.contains("hue-360"), "{css}");
462- }
463462
464- #[tokio::test]
465- async fn custom_css_with_no_hue_is_empty_and_never_an_error() {
466- let router: Router = Router::builder().discover().cookies().build();
467463 for uri in ["/theme/custom.css", "/theme/custom.css?al=hue-x&bd=%00"] {
468464 let req = Request::builder()
469465 .method("GET")
crates/forge-web/src/pages/settings_appearance.rsmodified+1 -7
@@ -612,7 +612,7 @@ mod tests {
612612 }
613613
614614 #[test]
615- fn a_stored_hue_checks_custom_and_sets_the_knob() {
615+ fn a_stored_hue_checks_custom_and_a_stored_preset_moves_the_knob() {
616616 let group = colour_group(Lang::En, false, "hue-200", "hue-40");
617617 assert!(group.base_stripe.custom);
618618 assert_eq!(group.base_stripe.hue, 200);
@@ -620,10 +620,7 @@ mod tests {
620620 assert_eq!(group.accent_stripe.hue, 40);
621621 assert!(group.bases.iter().all(|c| !c.selected));
622622 assert!(group.accents.iter().all(|c| !c.selected));
623- }
624623
625- #[test]
626- fn a_stored_preset_checks_the_preset_and_moves_the_knob_to_its_hue() {
627624 let group = colour_group(Lang::En, true, "ink", "plum");
628625 let plum_hue = preset_accent_hue("plum").unwrap();
629626 let ink_hue = preset_base_hue("ink").unwrap();
@@ -634,10 +631,7 @@ mod tests {
634631 let plum = group.accents.iter().find(|c| c.value == "plum").unwrap();
635632 assert!(plum.selected);
636633 assert_eq!(plum.hue, plum_hue.to_string());
637- }
638634
639- #[test]
640- fn a_stored_hue_is_only_read_in_range() {
641635 assert_eq!(hue_of("hue-359"), Some(359));
642636 assert_eq!(hue_of("hue-360"), None);
643637 assert_eq!(hue_of("hue-"), None);