use std::{fs, path::Path};
use rbx_dom_weak::DomViewer;
use crate::{from_reader, text_deserializer::DecodedModel, to_writer};
pub fn run_model_base_suite(model_path: impl AsRef<Path>) {
let model_path = model_path.as_ref();
let model_stem = model_path
.parent()
.unwrap()
.file_stem()
.unwrap()
.to_str()
.unwrap();
let contents = fs::read(model_path).unwrap();
let text_decoded = DecodedModel::from_reader(contents.as_slice());
insta::assert_yaml_snapshot!(format!("{}__input", model_stem), text_decoded);
let decoded = from_reader(contents.as_slice()).unwrap();
let decoded_viewed = DomViewer::new().view_children(&decoded);
insta::assert_yaml_snapshot!(format!("{}__decoded", model_stem), decoded_viewed);
let decoded_root = decoded.root();
let top_level_ids = decoded_root.children();
let mut encoded = Vec::new();
to_writer(&mut encoded, &decoded, top_level_ids).unwrap();
let text_roundtrip = DecodedModel::from_reader(encoded.as_slice());
insta::assert_yaml_snapshot!(format!("{}__encoded", model_stem), text_roundtrip);
from_reader(encoded.as_slice()).unwrap();
}