icons: Add test to ensure all icon variants exist (#61337)
This is just to help with bookkeeping, as we currently do not ensure anywhere icons do actually exist. Release Notes: - N/A
This commit is contained in:
1 parent
913a81546d
commit
3e78d2068e
2 files changed
+42
-8
No files matched your search
@@ -1,8 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.78125 14.9375C4.35078 14.9375 4.8125 14.4758 4.8125 13.9063C4.8125 13.3367 4.35078 12.875 3.78125 12.875C3.21171 12.875 2.75 13.3367 2.75 13.9063C2.75 14.4758 3.21171 14.9375 3.78125 14.9375Z" fill="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.46876 9.18684L4.69485 14.4063L2.875 13.4382L5.64891 8.21875L7.46876 9.18684Z" fill="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.43749 2.99935L5.64475 8.21876L3.8125 7.25066L6.60524 2.03125L8.43749 2.99935Z" fill="black"/>
|
||||
<path d="M7.5 3.53124C8.06953 3.53124 8.53124 3.06954 8.53124 2.5C8.53124 1.93045 8.06953 1.46875 7.5 1.46875C6.93046 1.46875 6.46875 1.93045 6.46875 2.5C6.46875 3.06954 6.93046 3.53124 7.5 3.53124Z" fill="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.4366 1.49947C12.8962 1.61399 13.2187 2.02651 13.2187 2.49985V13.9063H11.1552V6.63497L9.29072 10.1392L7.46875 9.1711L11.276 2.01583C11.4984 1.5979 11.977 1.38496 12.4366 1.49947Z" fill="black"/>
|
||||
<path d="M12.1875 14.9375C12.757 14.9375 13.2187 14.4758 13.2187 13.9063C13.2187 13.3367 12.757 12.875 12.1875 12.875C11.6179 12.875 11.1562 13.3367 11.1562 13.9063C11.1562 14.4758 11.6179 14.9375 12.1875 14.9375Z" fill="black"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -309,3 +309,45 @@ impl IconName {
|
||||
format!("icons/{file_stem}.svg").into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use strum::{IntoEnumIterator as _, ParseError};
|
||||
|
||||
use crate::IconName;
|
||||
|
||||
#[test]
|
||||
fn test_all_icons_exist() {
|
||||
let asset_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets");
|
||||
|
||||
for icon in IconName::iter() {
|
||||
let icon_path = asset_path.join(&*icon.path());
|
||||
assert!(
|
||||
icon_path.exists(),
|
||||
"Icon {icon:?} does not exist at {icon_path:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_dangling_icons() -> Result<(), ParseError> {
|
||||
let icons_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/icons");
|
||||
|
||||
for entry in std::fs::read_dir(&icons_dir).expect("failed to read icons directory") {
|
||||
let path = entry.expect("failed to read icons directory entry").path();
|
||||
if path.extension().is_none_or(|extension| extension != "svg") {
|
||||
continue;
|
||||
}
|
||||
let file_stem = path
|
||||
.file_stem()
|
||||
.and_then(|file_stem| file_stem.to_str())
|
||||
.expect("icon file name is not valid UTF-8");
|
||||
|
||||
file_stem.parse::<IconName>()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user