pub(crate) struct Deprecation {
pub id: &'static str,
pub message: String,
pub more_info: Option<String>,
}
impl Deprecation {
pub(crate) fn import() -> Self {
Deprecation {
id: "import",
message: "Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.".to_string(),
more_info: Some("More info and automated migrator: https://sass-lang.com/d/import".to_string()),
}
}
pub(crate) fn render_header(&self) -> String {
let mut out = format!("DEPRECATION WARNING [{}]: {}\n", self.id, self.message);
if let Some(info) = &self.more_info {
out.push('\n');
out.push_str(info);
out.push('\n');
}
out.push('\n');
out
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn import_header_matches_fixture_prefix() {
let d = Deprecation::import();
let expected = "\
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
";
assert_eq!(d.render_header(), expected);
}
}