use egui_kittest::wgpu::{create_render_state, default_wgpu_setup};
use rsplot::egui::Color32;
use rsplot::{Plot1D, YAxis};
#[test]
fn right_axis_only_plot_refits_on_reset() {
let rs = create_render_state(default_wgpu_setup());
rsplot::install(&rs);
let mut plot = Plot1D::new(&rs, 0);
let xs: Vec<f64> = (0..=10).map(|i| i as f64).collect();
let ys: Vec<f64> = xs.iter().map(|x| 100.0 + 10.0 * x).collect();
let h = plot.add_curve(&xs, &ys, Color32::RED);
assert!(plot.set_curve_y_axis(h, YAxis::Right));
plot.plot_mut().limits = (0.0, 1.0, 0.0, 1.0);
plot.reset_zoom_to_data();
let limits = plot.plot().limits;
let y2 = plot.plot().y2.expect("right axis created from right data");
assert_eq!((limits.0, limits.1), (0.0, 10.0), "{limits:?}");
assert_eq!((limits.2, limits.3), y2, "left adopts the right range");
assert_eq!(y2, (100.0, 200.0));
}
#[test]
fn itemless_reset_lands_on_silx_home_view() {
let rs = create_render_state(default_wgpu_setup());
rsplot::install(&rs);
let mut plot = Plot1D::new(&rs, 0);
plot.plot_mut().limits = (3.0, 7.0, 2.0, 8.0);
plot.reset_zoom_to_data();
assert_eq!(plot.plot().limits, (1.0, 100.0, 1.0, 100.0));
assert_eq!(plot.plot().y2, None);
}