mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-24 18:36:44 -06:00
* Dev profile: line tables for workspace crates, no debug info for dependencies * Tests: one integration-test binary per crate with several test files * xtask ci: nextest, doctests, tests without examples, --keep-going; add xtask test
25 lines
1.3 KiB
Rust
25 lines
1.3 KiB
Rust
use figcraft_engine::Session;
|
|
use serde_json::json;
|
|
|
|
fn scopes(session: &Session, variable: &str) -> Option<Vec<String>> {
|
|
session.doc().unwrap().variables.get(variable).unwrap().scopes.clone()
|
|
}
|
|
|
|
#[test]
|
|
fn null_restores_all_supported_properties() {
|
|
let mut session = Session::new();
|
|
session.execute("variable.createCollection", &json!({"name": "Theme"})).unwrap();
|
|
let result = session.execute("variable.create", &json!({"collection": "Theme", "name": "Accent", "type": "color"})).unwrap();
|
|
let variable = result["id"].as_str().unwrap();
|
|
assert_eq!(scopes(&session, variable), None);
|
|
session.execute("variable.update", &json!({"variable": variable, "scopes": []})).unwrap();
|
|
assert_eq!(scopes(&session, variable), Some(vec![]));
|
|
session.execute("variable.update", &json!({"variable": variable, "name": "Accent2"})).unwrap();
|
|
assert_eq!(scopes(&session, variable), Some(vec![]));
|
|
assert_eq!(session.execute("variable.update", &json!({"variable": variable, "scopes": null})).unwrap(), json!({"ok": true}));
|
|
assert_eq!(scopes(&session, variable), None);
|
|
session.execute("variable.update", &json!({"variable": variable, "scopes": []})).unwrap();
|
|
session.execute("variable.update", &json!({"variable": variable, "scopes": ["ALL_SCOPES"]})).unwrap();
|
|
assert_eq!(scopes(&session, variable), None);
|
|
}
|