servo/tests/unit/style/properties/scaffolding.rs
Simon Sapin 0215d09ccb Generate apis.html and css-properties.json for docs as part of crates’ build scripts
… rather than as an extra step after `cargo doc`.
This helps always using the correct set of CSS properties
(for layout 2013 v.s. 2020).
2019-07-30 08:37:33 +02:00

27 lines
890 B
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use serde_json::{self, Value};
use std::env;
use std::fs::File;
use std::path::Path;
#[test]
fn properties_list_json() {
let top = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap())
.join("..")
.join("..")
.join("..");
let json = top
.join("target")
.join("doc")
.join("servo")
.join("css-properties.json");
let properties: Value = serde_json::from_reader(File::open(json).unwrap()).unwrap();
let longhands = properties["longhands"].as_object().unwrap();
assert!(longhands.len() > 100);
assert!(longhands.get("margin-top").is_some());
assert!(properties["shorthands"].get("margin").is_some());
}