mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-10 03:49:40 +00:00
Use pretty_assertions, fix deleted items notification test
This commit is contained in:
parent
2c511eead9
commit
9abdff79f5
4 changed files with 36 additions and 4 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -37,6 +37,7 @@ dependencies = [
|
|||
"console_error_panic_hook",
|
||||
"getrandom",
|
||||
"indoc",
|
||||
"pretty_assertions",
|
||||
"scraper",
|
||||
"serde",
|
||||
"serde-wasm-bindgen 0.6.5",
|
||||
|
@ -168,6 +169,12 @@ dependencies = [
|
|||
"syn 2.0.68",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "1.0.9"
|
||||
|
@ -624,6 +631,16 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||
|
||||
[[package]]
|
||||
name = "pretty_assertions"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66"
|
||||
dependencies = [
|
||||
"diff",
|
||||
"yansi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.86"
|
||||
|
@ -1222,6 +1239,12 @@ dependencies = [
|
|||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yansi"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.34"
|
||||
|
|
|
@ -23,3 +23,6 @@ indoc = "2.0.5"
|
|||
# WebAssembly support.
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
serde-wasm-bindgen = "0.6.5"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.4.0"
|
||||
|
|
|
@ -73,6 +73,7 @@ pub fn format_deleted_item(item: &ShopItem) -> String {
|
|||
mod format_new_tests {
|
||||
use super::*;
|
||||
use indoc::indoc;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn item_formatted() {
|
||||
|
|
13
src/lib.rs
13
src/lib.rs
|
@ -103,8 +103,10 @@ fn diff_old_new_items(old_items: &ShopItems, new_items: &ShopItems) -> Vec<Strin
|
|||
#[cfg(test)]
|
||||
mod diff_old_new_items_tests {
|
||||
use super::*;
|
||||
use indoc::indoc;
|
||||
|
||||
use indoc::formatdoc;
|
||||
use items::ShopItem;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn deleted_items_notification() {
|
||||
|
@ -130,9 +132,12 @@ mod diff_old_new_items_tests {
|
|||
assert_eq!(
|
||||
result[0],
|
||||
formatdoc! {
|
||||
"*Item DELETED:* Item 2
|
||||
*Description:* Description 2
|
||||
*Price:* 200"
|
||||
"*Item DELETED:* {full_name}
|
||||
*Description:* {description}
|
||||
*Price:* {price}",
|
||||
full_name = item_2.full_name,
|
||||
description = item_2.description.as_ref().unwrap_or(&"_not set_".into()),
|
||||
price = item_2.price,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue