@@ -74,35 +74,41 @@ const oldHistoryPath = path.join(fixtures, 'old-repl-history-file.json');
74
74
const tests = [ {
75
75
env : { NODE_REPL_HISTORY : '' } ,
76
76
test : [ UP ] ,
77
- expected : [ prompt , replDisabled , prompt ]
77
+ expected : [ prompt , replDisabled , prompt ] ,
78
+ event : 'end'
78
79
} ,
79
80
{
80
81
env : { NODE_REPL_HISTORY : '' ,
81
82
NODE_REPL_HISTORY_FILE : oldHistoryPath } ,
82
83
test : [ UP ] ,
83
- expected : [ prompt , replDisabled , prompt ]
84
+ expected : [ prompt , replDisabled , prompt ] ,
85
+ event : 'end'
84
86
} ,
85
87
{
86
88
env : { NODE_REPL_HISTORY : historyPath } ,
87
89
test : [ UP , CLEAR ] ,
88
- expected : [ prompt , prompt + '\'you look fabulous today\'' , prompt ]
90
+ expected : [ prompt , prompt + '\'you look fabulous today\'' , prompt ] ,
91
+ event : 'end'
89
92
} ,
90
93
{
91
94
env : { NODE_REPL_HISTORY : historyPath ,
92
95
NODE_REPL_HISTORY_FILE : oldHistoryPath } ,
93
96
test : [ UP , CLEAR ] ,
94
- expected : [ prompt , prompt + '\'you look fabulous today\'' , prompt ]
97
+ expected : [ prompt , prompt + '\'you look fabulous today\'' , prompt ] ,
98
+ event : 'end'
95
99
} ,
96
100
{
97
101
env : { NODE_REPL_HISTORY : historyPath ,
98
102
NODE_REPL_HISTORY_FILE : '' } ,
99
103
test : [ UP , CLEAR ] ,
100
- expected : [ prompt , prompt + '\'you look fabulous today\'' , prompt ]
104
+ expected : [ prompt , prompt + '\'you look fabulous today\'' , prompt ] ,
105
+ event : 'end'
101
106
} ,
102
107
{
103
108
env : { } ,
104
109
test : [ UP ] ,
105
- expected : [ prompt ]
110
+ expected : [ prompt ] ,
111
+ event : 'end'
106
112
} ,
107
113
{
108
114
env : { NODE_REPL_HISTORY_FILE : oldHistoryPath } ,
@@ -123,13 +129,15 @@ const tests = [{
123
129
const historyCopy = fs . readFileSync ( historyPath , 'utf8' ) ;
124
130
assert . strictEqual ( historyCopy , '\'you look fabulous today\'' + os . EOL +
125
131
'\'Stay Fresh~\'' + os . EOL ) ;
126
- }
132
+ } ,
133
+ event : 'flushHistory'
127
134
} ,
128
135
{
129
136
env : { } ,
130
137
test : [ UP , UP , ENTER ] ,
131
138
expected : [ prompt , prompt + '\'42\'' , prompt + '\'=^.^=\'' , '\'=^.^=\'\n' ,
132
- prompt ]
139
+ prompt ] ,
140
+ event : 'flushHistory'
133
141
} ,
134
142
{ // Make sure this is always the last test, since we change os.homedir()
135
143
before : function mockHomedirFailure ( ) {
@@ -140,7 +148,8 @@ const tests = [{
140
148
} ,
141
149
env : { } ,
142
150
test : [ UP ] ,
143
- expected : [ prompt , homedirErr , prompt , replDisabled , prompt ]
151
+ expected : [ prompt , homedirErr , prompt , replDisabled , prompt ] ,
152
+ event : 'end'
144
153
} ] ;
145
154
146
155
@@ -180,9 +189,9 @@ function runTest() {
180
189
} , function ( err , repl ) {
181
190
if ( err ) throw err ;
182
191
183
- if ( after ) repl . on ( 'close' , after ) ;
192
+ if ( after ) repl . on ( opts . event , after ) ;
184
193
185
- repl . on ( 'close' , function ( ) {
194
+ repl . on ( opts . event , function ( ) {
186
195
// Ensure everything that we expected was output
187
196
assert . strictEqual ( expected . length , 0 ) ;
188
197
setImmediate ( runTest ) ;
0 commit comments