source · Rust

Presentation Tools

crates/vak-core/src/presentation_tools.rs
Raw
55.4 KB1,441 lines11 anchorsSnapshot ed4ab258
  1. 1413 "semantic_type": "chart",
  2. 1414 "payload": {
  3. 1415 "title": "Revenue",
  4. 1416 "chart_type": "line",
  5. 1417 "accessible_summary": "flat",
  6. 1418 "series": [{"name": "s1", "points": [{"x": 1, "y": 2.0}]}]
  7. 1419 }
  8. 1420 });
  9. 1421 let info = presentation_info("emit_chart_card", &args, &skills)
  10. 1422 .expect("a valid call must rebuild");
  11. 1423 assert_eq!(info.semantic_type, "chart");
  12. 1424 assert_eq!(info.title, "Revenue");
  13. 1425 assert!(
  14. 1426 info.identity_digest.contains("s1(1)"),
  15. 1427 "{}",
  16. 1428 info.identity_digest
  17. 1429 );
  18. 1430 assert!(info.schema_version > 0);
  19. 1431 assert!(!info.skill_id.is_empty());
  20. 1432 }
  21. 1433
  22. 1434 #[test]
  23. 1435 fn presentation_info_is_none_for_an_invalid_call() {
  24. 1436 let skills = vak_delivery::built_in_skill_registry();
  25. 1437 let args = serde_json::json!({"semantic_type": "chart", "payload": {"series": []}});
  26. 1438 assert!(presentation_info("emit_chart_card", &args, &skills).is_none());
  27. 1439 }
  28. 1440}
  29. 1441