mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-16 22:01:22 +01:00
test(kde): pin the JSON of Container
Before the container moves into a shared crate: a test that fixes the serialised form of komorebi-for-kde's Container, field by field (id, locked, windows with elements and focused), for an empty container and for one with two windows, so the move cannot change what `komorebic state` prints. Verified: KDE cargo test -p komorebi --lib container (native, lite env): 50 passed, 0 failed. Not run: the rest.
This commit is contained in:
1 parent
23fd0a8c41
commit
2d2dff101c
1 file changed
+23
@@ -287,6 +287,29 @@ mod tests {
|
||||
assert_eq!(container.idx_for_window(4), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_json_of_a_container_is_its_id_whether_it_is_locked_and_the_ring_of_windows() {
|
||||
let mut container = Container {
|
||||
id: "c1".to_string(),
|
||||
locked: true,
|
||||
windows: Default::default(),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&container).unwrap(),
|
||||
r#"{"id":"c1","locked":true,"windows":{"elements":[],"focused":0}}"#
|
||||
);
|
||||
|
||||
container.add_window(Window::from(5));
|
||||
container.add_window(Window::from(9));
|
||||
container.focus_window(0);
|
||||
|
||||
let json = serde_json::to_string(&container).unwrap();
|
||||
assert!(json.starts_with(r#"{"id":"c1","locked":true,"windows":{"elements":[{"id":5,"#));
|
||||
assert!(json.contains(r#"},{"id":9,"#));
|
||||
assert!(json.ends_with(r#"}],"focused":0}}"#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serializes_and_deserializes() {
|
||||
let mut container = Container::default();
|
||||
|
||||
Reference in new issue
Block a user