Skip to content

Commit c7d4d7f

Browse files
committed
Added tests for actions not present on actual or present on both
1 parent f46b804 commit c7d4d7f

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

gui/base/src/test/java/it/angrybear/yagl/guis/GUIImplTest.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,55 @@ void testCopyAllNoReplace() {
8989
assertEquals(expected, actual);
9090
}
9191

92+
@Test
93+
void testCopyAllActionsNoReplace() {
94+
GUI expected = GUI.newGUI(9).setTitle("Hello")
95+
.setVariable("hello", "world")
96+
.setContents(0, ItemGUIContent.newInstance("stone"))
97+
.addContent(ItemGUIContent.newInstance("diamond"))
98+
.onOpenGUI("command")
99+
.onChangeGUI("command")
100+
.onCloseGUI("command")
101+
.onClickOutside("command");
102+
GUI actual = GUI.newGUI(9).setTitle("Hi").copyFrom(expected, false);
103+
assertEquals("Hi", actual.getTitle());
104+
actual.setTitle(expected.getTitle())
105+
.onOpenGUI("command")
106+
.onChangeGUI("command")
107+
.onCloseGUI("command")
108+
.onClickOutside("command");
109+
assertEquals(expected, actual);
110+
}
111+
112+
@Test
113+
void testCopyAllActionsOnActualNoReplace() {
114+
GUI expected = GUI.newGUI(9).setTitle("Hello")
115+
.setVariable("hello", "world")
116+
.setContents(0, ItemGUIContent.newInstance("stone"))
117+
.addContent(ItemGUIContent.newInstance("diamond"))
118+
.onOpenGUI("command")
119+
.onChangeGUI("command")
120+
.onCloseGUI("command")
121+
.onClickOutside("command");
122+
GUI actual = GUI.newGUI(9).setTitle("Hi")
123+
.onOpenGUI("command1")
124+
.onChangeGUI("command1")
125+
.onCloseGUI("command1")
126+
.onClickOutside("command1")
127+
.copyFrom(expected, false);
128+
assertEquals("Hi", actual.getTitle());
129+
assertNotEquals(actual.openGUIAction().get(), expected.openGUIAction().get());
130+
assertNotEquals(actual.changeGUIAction().get(), expected.changeGUIAction().get());
131+
assertNotEquals(actual.closeGUIAction().get(), expected.closeGUIAction().get());
132+
assertNotEquals(actual.clickOutsideAction().get(), expected.clickOutsideAction().get());
133+
actual.setTitle(expected.getTitle())
134+
.onOpenGUI("command")
135+
.onChangeGUI("command")
136+
.onCloseGUI("command")
137+
.onClickOutside("command");
138+
assertEquals(expected, actual);
139+
}
140+
92141
@Test
93142
void testCopyAllReplace() {
94143
GUI expected = GUI.newGUI(9).setTitle("Hello")
@@ -100,6 +149,25 @@ void testCopyAllReplace() {
100149
assertEquals(expected, actual);
101150
}
102151

152+
@Test
153+
void testCopyAllActionsOnActualAllReplace() {
154+
GUI expected = GUI.newGUI(9).setTitle("Hello")
155+
.setVariable("hello", "world")
156+
.setContents(0, ItemGUIContent.newInstance("stone"))
157+
.addContent(ItemGUIContent.newInstance("diamond"))
158+
.onOpenGUI("command")
159+
.onChangeGUI("command")
160+
.onCloseGUI("command")
161+
.onClickOutside("command");
162+
GUI actual = GUI.newGUI(9).setTitle("Hi")
163+
.onOpenGUI("command1")
164+
.onChangeGUI("command1")
165+
.onCloseGUI("command1")
166+
.onClickOutside("command1")
167+
.copyFrom(expected, true);
168+
assertEquals(expected, actual);
169+
}
170+
103171
@Test
104172
void testCopyDifferentSizes() {
105173
assertThrowsExactly(IllegalArgumentException.class, () ->

0 commit comments

Comments
 (0)