-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ssg): ✅ Add new unit tests for
ssg-template
- Loading branch information
1 parent
94b1939
commit 730c241
Showing
4 changed files
with
650 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use ssg_template::Context; | ||
|
||
#[test] | ||
fn test_context_new() { | ||
let context = Context::new(); | ||
assert!(context.elements.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn test_context_set_and_get() { | ||
let mut context = Context::new(); | ||
context.set("name", "Alice"); | ||
assert_eq!(context.get("name"), Some(&"Alice")); | ||
} | ||
|
||
#[test] | ||
fn test_context_update_existing_key() { | ||
let mut context = Context::new(); | ||
context.set("name", "Alice"); | ||
context.set("name", "Bob"); | ||
assert_eq!(context.get("name"), Some(&"Bob")); | ||
} | ||
|
||
#[test] | ||
fn test_context_get_nonexistent_key() { | ||
let context = Context::new(); | ||
assert_eq!(context.get("nonexistent"), None); | ||
} | ||
|
||
#[test] | ||
fn test_context_multiple_entries() { | ||
let mut context = Context::new(); | ||
context.set("name", "Alice"); | ||
context.set("age", "30"); | ||
assert_eq!(context.get("name"), Some(&"Alice")); | ||
assert_eq!(context.get("age"), Some(&"30")); | ||
} |
Oops, something went wrong.