Repository navigation
Expand file tree
/
Copy pathModuleBlockTest.java
More file actions
63 lines (52 loc) · 1.48 KB
/
Copy pathModuleBlockTest.java
File metadata and controls
63 lines (52 loc) · 1.48 KB
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
package utils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ModuleBlockTest {
@BeforeEach
void resetState() {
ModuleBlock.reset();
}
@Test
void reset_clearsBlockerId() {
ModuleBlock.blockerId = "someId";
ModuleBlock.reset();
assertEquals("", ModuleBlock.blockerId);
}
@Test
void reset_clearsMessage() {
ModuleBlock.setMessage("blocked");
ModuleBlock.reset();
assertEquals("", ModuleBlock.getBlockerMessage());
}
@Test
void reset_disablesBlocker() {
ModuleBlock.blockerEnabled = true;
ModuleBlock.reset();
assertFalse(ModuleBlock.blockerEnabled);
}
@Test
void setAndGetMessage_roundTrip() {
ModuleBlock.setMessage("Test Message");
assertEquals("Test Message", ModuleBlock.getBlockerMessage());
}
@Test
void getBlockerMessage_encodesHtml() {
ModuleBlock.setMessage("<script>alert(1)</script>");
String result = ModuleBlock.getBlockerMessage();
assertFalse(result.contains("<script>"));
}
@Test
void getBlockerMessage_encodesAmpersand() {
ModuleBlock.setMessage("A & B");
String result = ModuleBlock.getBlockerMessage();
assertFalse(result.contains(" & "));
}
@Test
void getBlockerMessage_emptyAfterReset() {
ModuleBlock.setMessage("something");
ModuleBlock.reset();
assertEquals("", ModuleBlock.getBlockerMessage());
}
}