#[test]
fn js_warning_kind_table_covers_known_kinds() {
let warnings_ts = include_str!("../../../../js/src/devtools/warnings.ts");
for kind in [
"display",
"boxSizing",
"positionType",
"overflow",
"alignItems",
"justifyItems",
"alignSelf",
"justifySelf",
"alignContent",
"justifyContent",
"flexDirection",
"flexWrap",
"gridAutoFlow",
"focusPolicy",
"textAlign",
"lineBreak",
"fontSize",
"fontWeight",
"rect",
"gridTrack",
"gridPlacement",
"borderColor",
"filterParams",
"filterUnknown",
"filterBleed",
"filterBinding",
"backdropFilterParams",
"backdropFilterUnknown",
"backdropFilterBinding",
"scrollbar",
"styleBinding",
"backgroundImage",
"svgImageAttrs",
"svgShapeScroll",
"viewBox",
"shapePath",
"shapePoints",
"shapePaint",
"shapeEnum",
"shapeTransform",
"shapeTransition",
"shapeBinding",
"color",
"fontFamily",
"cursor",
"lineHeight",
"letterSpacing",
"cache",
] {
assert!(
warnings_ts.contains(&format!("{kind}:"))
|| warnings_ts.contains(&format!("\"{kind}\":")),
"js/src/devtools/warnings.ts KIND_FIELDS is missing kind \"{kind}\""
);
}
}
#[test]
fn js_style_field_table_covers_every_style_field() {
let fields_ts = include_str!("../../../../js/src/devtools/fields.ts");
macro_rules! check_fields {
($(($field:ident, $wire:literal, ($($group:tt)*), $overlay:ident)),* $(,)?) => {
$(
assert!(
fields_ts.contains(concat!($wire, ":"))
|| fields_ts.contains(concat!("\"", $wire, "\":")),
concat!(
"js/src/devtools/fields.ts is missing style field \"",
$wire,
"\" — add it to STYLE_FIELDS with a category"
)
);
)*
};
}
crate::protocol::style::with_style_fields!(check_fields);
}
#[test]
fn js_shape_field_table_covers_shape_attrs() {
let crate::svg::ShapeAttrs {
x: _,
y: _,
width: _,
height: _,
cx: _,
cy: _,
r: _,
rx: _,
ry: _,
x1: _,
y1: _,
x2: _,
y2: _,
points: _,
d: _,
fill: _,
stroke: _,
stroke_width: _,
opacity: _,
fill_rule: _,
stroke_linecap: _,
stroke_linejoin: _,
transform: _,
transition: _,
} = crate::svg::ShapeAttrs::default();
let fields_ts = include_str!("../../../../js/src/devtools/fields.ts");
let table = fields_ts
.split_once("SHAPE_FIELDS")
.and_then(|(_, rest)| rest.split_once("};"))
.map(|(table, _)| table)
.expect("js/src/devtools/fields.ts has no SHAPE_FIELDS table");
for field in [
"d",
"x",
"y",
"width",
"height",
"cx",
"cy",
"r",
"rx",
"ry",
"x1",
"y1",
"x2",
"y2",
"points",
"fill",
"stroke",
"strokeWidth",
"opacity",
"fillRule",
"strokeLinecap",
"strokeLinejoin",
"transform",
"transition",
] {
assert!(
table.contains(&format!("\n {field}:"))
|| table.contains(&format!("\n \"{field}\":")),
"js/src/devtools/fields.ts SHAPE_FIELDS is missing shape field \"{field}\""
);
}
let jsx_svg = include_str!("../../../../js/src/jsx-svg.d.ts");
let union = jsx_svg
.split_once("BevyShapeTransition")
.and_then(|(_, rest)| rest.split_once("};"))
.map(|(body, _)| body)
.expect("js/src/jsx-svg.d.ts has no BevyShapeTransition type");
for (name, _, _) in &crate::svg::NUMERIC_ATTRS {
assert!(
union.contains(&format!("\"{name}\"")),
"js/src/jsx-svg.d.ts BevyShapeTransition is missing numeric attr \"{name}\""
);
}
}