@@ -16,6 +16,7 @@ public class UpdateTextAreaActionTest {
16
16
@ Before public void setUp () {
17
17
textAreaFIFO = mock (TextAreaFIFO .class );
18
18
text = ArgumentCaptor .forClass (String .class );
19
+ sendNewLineInOrderToHaveCleanTestStart ();
19
20
}
20
21
21
22
@ Test
@@ -64,4 +65,36 @@ public void emptyLinesHaveTimestampToo() {
64
65
+ TIMESTAMP_REGEX + " -> line_2" );
65
66
}
66
67
68
+ @ Test
69
+ public void newLinesAreRememberedWhenNewBufferIsUsed () {
70
+ // given #1
71
+ AbstractTextMonitor .UpdateTextAreaAction action ;
72
+ action = new AbstractTextMonitor .UpdateTextAreaAction (
73
+ textAreaFIFO , true , false , "first line without newline" );
74
+
75
+ // when #1
76
+ action .run ();
77
+
78
+ //then #1
79
+ verify (textAreaFIFO , atLeastOnce ()).append (text .capture ());
80
+ assertThat (text .getValue ()).matches (TIMESTAMP_REGEX + " -> first line without newline" );
81
+
82
+ // given #2
83
+ action = new AbstractTextMonitor .UpdateTextAreaAction (
84
+ textAreaFIFO , true , false , "more text for first line" );
85
+
86
+ // when #2
87
+ action .run ();
88
+
89
+ //then #2
90
+ verify (textAreaFIFO , atLeastOnce ()).append (text .capture ());
91
+ assertThat (text .getValue ()).matches ("more text for first line" );
92
+ }
93
+
94
+
95
+ private void sendNewLineInOrderToHaveCleanTestStart () {
96
+ AbstractTextMonitor .UpdateTextAreaAction action = new AbstractTextMonitor .UpdateTextAreaAction (
97
+ textAreaFIFO , true , false , "\n " );
98
+ action .run ();
99
+ }
67
100
}
0 commit comments