Skip to content

Commit

Permalink
add test for remove_items
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x committed Jun 13, 2024
1 parent c5beda3 commit 359a94e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crates/dojo-world/src/manifest/manifest_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use dojo_test_utils::compiler;
use dojo_test_utils::rpc::MockJsonRpcTransport;
use katana_runner::KatanaRunner;
use serde_json::json;
use smol_str::SmolStr;
use starknet::accounts::ConnectedAccount;
use starknet::core::types::contract::AbiEntry;
use starknet::core::types::{EmittedEvent, FieldElement};
Expand Down Expand Up @@ -655,3 +656,37 @@ fn overlay_merge_for_base_work_as_expected() {
current.merge(other);
assert_eq!(current, expected);
}

#[test]
fn base_manifest_remove_items_work_as_expected() {
let contracts = ["c1", "c2", "c3"];
let models = ["m1", "m2", "m3"];

let world = Manifest { name: "world".into(), inner: Default::default() };
let base = Manifest { name: "base".into(), inner: Default::default() };

let contracts = contracts
.iter()
.map(|c| Manifest { name: SmolStr::from(*c), inner: Default::default() })
.collect();
let models = models
.iter()
.map(|c| Manifest { name: SmolStr::from(*c), inner: Default::default() })
.collect();

let mut base = BaseManifest { contracts, models, world, base };

base.remove_items(vec!["c1".to_string(), "c3".to_string(), "m2".to_string()]);

assert_eq!(base.contracts.len(), 1);
assert_eq!(
base.contracts.iter().map(|c| c.name.clone().into()).collect::<Vec<String>>(),
vec!["c2"]
);

assert_eq!(base.models.len(), 2);
assert_eq!(
base.models.iter().map(|c| c.name.clone().into()).collect::<Vec<String>>(),
vec!["m1", "m3"]
);
}

0 comments on commit 359a94e

Please sign in to comment.