Skip to content

Commit 5b2f988

Browse files
committed
fix(test): all of those tests were actually good.. i was encountering OS error when saving snapshot
i'm an idiot...
1 parent 90504d8 commit 5b2f988

13 files changed

Lines changed: 107 additions & 43 deletions

src/notification.rs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -101,37 +101,13 @@ mod tests {
101101
use insta::assert_snapshot;
102102
use ratatui::{Terminal, backend::TestBackend};
103103
use rstest::rstest;
104+
use std::hash::{DefaultHasher, Hash, Hasher};
104105

105106
#[rstest]
106107
fn render_good(
107-
#[values("short", "with\nnewline")] message_str: &'static str,
108-
#[values(
109-
NotificationLevel::Info,
110-
NotificationLevel::Warning,
111-
NotificationLevel::Error
112-
)]
113-
level: NotificationLevel,
114-
) {
115-
let mut terminal = Terminal::new(TestBackend::new(80, 24)).unwrap();
116-
terminal
117-
.draw(|frame| {
118-
let notification = Notification {
119-
message: message_str.into(),
120-
level: level.clone(),
121-
ttl: 1,
122-
};
123-
notification.render(0, frame, frame.area());
124-
})
125-
.unwrap();
126-
127-
let snapshot_name = format!("{}-{:?}", message_str, level);
128-
assert_snapshot!(snapshot_name, terminal.backend());
129-
}
130-
131-
#[rstest]
132-
#[should_panic(expected = "File name too long")]
133-
fn render_bad(
134108
#[values(
109+
"short",
110+
"with\nnewline",
135111
"extremely long WITHOUT newline Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id mauris sit amet libero convallis fringilla quis non augue. In sollicitudin quam sed magna finibus, vitae malesuada magna porttitor. Pellentesque in dictum dui. Nullam nec mi venenatis, faucibus odio eget, molestie nisi. Fusce velit nibh, euismod vel lectus id, placerat.",
136112
r"extremely long WITH newline Lorem ipsum dolor sit amet, consectetur
137113
adipiscing elit. Sed id mauris sit amet libero convallis fringilla quis non
@@ -159,7 +135,11 @@ nisi. Fusce velit nibh, euismod vel lectus id, placerat."
159135
})
160136
.unwrap();
161137

162-
let snapshot_name = format!("{}-{:?}", message_str, level);
138+
let mut hasher = DefaultHasher::new();
139+
message_str.hash(&mut hasher);
140+
let hash = hasher.finish();
141+
142+
let snapshot_name = format!("{}-{:?}", hash, level);
163143
assert_snapshot!(snapshot_name, terminal.backend());
164144
}
165145
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
source: src/notification.rs
3+
expression: terminal.backend()
4+
---
5+
" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ "
6+
" ┃ Error ┃ "
7+
" ┃ extremely long WITH newline Lorem ipsum dolor sit amet, consectetur ┃ "
8+
" ┃adipiscing elit. Sed id mauris sit amet libero convallis fringilla quis non┃ "
9+
" ┃ augue. In sollicitudin quam sed magna finibus, vitae malesuada magna ┃ "
10+
" ┃ porttitor. ┃ "
11+
" ┃ Pellentesque in dictum dui. Nullam nec mi venenatis, faucibus odio eget, ┃ "
12+
" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ "
13+
" "
14+
" "
15+
" "
16+
" "
17+
" "
18+
" "
19+
" "
20+
" "
21+
" "
22+
" "
23+
" "
24+
" "
25+
" "
26+
" "
27+
" "
28+
" "
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
source: src/notification.rs
3+
expression: terminal.backend()
4+
---
5+
" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ "
6+
" ┃ Info ┃ "
7+
" ┃ extremely long WITH newline Lorem ipsum dolor sit amet, consectetur ┃ "
8+
" ┃adipiscing elit. Sed id mauris sit amet libero convallis fringilla quis non┃ "
9+
" ┃ augue. In sollicitudin quam sed magna finibus, vitae malesuada magna ┃ "
10+
" ┃ porttitor. ┃ "
11+
" ┃ Pellentesque in dictum dui. Nullam nec mi venenatis, faucibus odio eget, ┃ "
12+
" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ "
13+
" "
14+
" "
15+
" "
16+
" "
17+
" "
18+
" "
19+
" "
20+
" "
21+
" "
22+
" "
23+
" "
24+
" "
25+
" "
26+
" "
27+
" "
28+
" "
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
source: src/notification.rs
3+
expression: terminal.backend()
4+
---
5+
" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ "
6+
" ┃ Warning ┃ "
7+
" ┃ extremely long WITH newline Lorem ipsum dolor sit amet, consectetur ┃ "
8+
" ┃adipiscing elit. Sed id mauris sit amet libero convallis fringilla quis non┃ "
9+
" ┃ augue. In sollicitudin quam sed magna finibus, vitae malesuada magna ┃ "
10+
" ┃ porttitor. ┃ "
11+
" ┃ Pellentesque in dictum dui. Nullam nec mi venenatis, faucibus odio eget, ┃ "
12+
" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ "
13+
" "
14+
" "
15+
" "
16+
" "
17+
" "
18+
" "
19+
" "
20+
" "
21+
" "
22+
" "
23+
" "
24+
" "
25+
" "
26+
" "
27+
" "
28+
" "

src/snapshots/bluetui__notification__tests__short-Error.snap renamed to src/snapshots/bluetui__notification__tests__11353925441405961020-Error.snap

File renamed without changes.

src/snapshots/bluetui__notification__tests__short-Info.snap renamed to src/snapshots/bluetui__notification__tests__11353925441405961020-Info.snap

File renamed without changes.

src/snapshots/bluetui__notification__tests__short-Warning.snap renamed to src/snapshots/bluetui__notification__tests__11353925441405961020-Warning.snap

File renamed without changes.

src/snapshots/bluetui__notification__tests__with newline-Error.snap renamed to src/snapshots/bluetui__notification__tests__15528810436234314490-Error.snap

File renamed without changes.

src/snapshots/bluetui__notification__tests__with newline-Info.snap renamed to src/snapshots/bluetui__notification__tests__15528810436234314490-Info.snap

File renamed without changes.

src/snapshots/bluetui__notification__tests__with newline-Warning.snap renamed to src/snapshots/bluetui__notification__tests__15528810436234314490-Warning.snap

File renamed without changes.

0 commit comments

Comments
 (0)