1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use super::CardTab;
use pretty_assertions::assert_eq;
// Covers: a browser call's card links the tab it acted on: the current one
// as it started, even when the call moved the current tab elsewhere; the
// one it opened when there was none; the one a new or switched-to tab
// call ends on; and none once that tab closed, as a popup that closed
// itself on a click. Otherwise a card links a tab the call never touched.
// Owner: browser tool card links
#[test]
fn a_card_links_the_tab_the_call_acted_on_while_it_is_open() {
let open = ["tab-1", "tab-2"];
let cases = [
(
"an act on the current tab",
CardTab::ActedOn,
Some("tab-1"),
Some("tab-1"),
Some("tab-1"),
),
(
"a navigate that opened the first tab",
CardTab::ActedOn,
None,
Some("tab-1"),
Some("tab-1"),
),
(
"a click that closed its popup",
CardTab::ActedOn,
Some("tab-3"),
Some("tab-1"),
None,
),
(
"a call naming its tab",
CardTab::Named("tab-2".into()),
Some("tab-1"),
Some("tab-1"),
Some("tab-2"),
),
(
"a new tab",
CardTab::Current,
Some("tab-1"),
Some("tab-2"),
Some("tab-2"),
),
(
"a tab list",
CardTab::Nothing,
Some("tab-1"),
Some("tab-1"),
None,
),
];
for (case, card, before, after, expected) in cases {
assert_eq!(
card.linked(before, after, |id| open.contains(&id)),
expected.map(str::to_owned),
"{case}"
);
}
}