@@ -29,7 +29,11 @@ ${file.content}`;
29
29
assert . equal ( Number ( project . getProjectVersion ( ) ) , expected ) ;
30
30
}
31
31
32
- function verify ( applyChangesToOpen : ( session : TestSession ) => void ) {
32
+ interface Verify {
33
+ applyChangesToOpen : ( session : TestSession ) => void ;
34
+ openFile1Again : ( session : TestSession ) => void ;
35
+ }
36
+ function verify ( { applyChangesToOpen, openFile1Again } : Verify ) {
33
37
const host = createServerHost ( [ app , file3 , commonFile1 , commonFile2 , libFile , configFile ] ) ;
34
38
const session = createSession ( host ) ;
35
39
session . executeCommandSeq < protocol . OpenRequest > ( {
@@ -65,11 +69,22 @@ ${file.content}`;
65
69
verifyText ( service , commonFile2 . path , fileContentWithComment ( commonFile2 ) ) ;
66
70
verifyText ( service , app . path , "let zzz = 10;let zz = 10;let z = 1;" ) ;
67
71
verifyText ( service , file3 . path , file3 . content ) ;
72
+
73
+ // Open file1 again
74
+ openFile1Again ( session ) ;
75
+ assert . isTrue ( service . getScriptInfo ( commonFile1 . path ) ! . isScriptOpen ( ) ) ;
76
+
77
+ // Verify that file1 contents are changed
78
+ verifyProjectVersion ( project , 4 ) ;
79
+ verifyText ( service , commonFile1 . path , commonFile1 . content ) ;
80
+ verifyText ( service , commonFile2 . path , fileContentWithComment ( commonFile2 ) ) ;
81
+ verifyText ( service , app . path , "let zzz = 10;let zz = 10;let z = 1;" ) ;
82
+ verifyText ( service , file3 . path , file3 . content ) ;
68
83
}
69
84
70
85
it ( "with applyChangedToOpenFiles request" , ( ) => {
71
- verify ( session =>
72
- session . executeCommandSeq < protocol . ApplyChangedToOpenFilesRequest > ( {
86
+ verify ( {
87
+ applyChangesToOpen : session => session . executeCommandSeq < protocol . ApplyChangedToOpenFilesRequest > ( {
73
88
command : protocol . CommandTypes . ApplyChangedToOpenFiles ,
74
89
arguments : {
75
90
openFiles : [
@@ -101,13 +116,22 @@ ${file.content}`;
101
116
file3 . path
102
117
]
103
118
}
104
- } )
105
- ) ;
119
+ } ) ,
120
+ openFile1Again : session => session . executeCommandSeq < protocol . ApplyChangedToOpenFilesRequest > ( {
121
+ command : protocol . CommandTypes . ApplyChangedToOpenFiles ,
122
+ arguments : {
123
+ openFiles : [ {
124
+ fileName : commonFile1 . path ,
125
+ content : commonFile1 . content
126
+ } ]
127
+ }
128
+ } ) ,
129
+ } ) ;
106
130
} ) ;
107
131
108
132
it ( "with updateOpen request" , ( ) => {
109
- verify ( session =>
110
- session . executeCommandSeq < protocol . UpdateOpenRequest > ( {
133
+ verify ( {
134
+ applyChangesToOpen : session => session . executeCommandSeq < protocol . UpdateOpenRequest > ( {
111
135
command : protocol . CommandTypes . UpdateOpen ,
112
136
arguments : {
113
137
openFiles : [
@@ -141,8 +165,17 @@ ${file.content}`;
141
165
file3 . path
142
166
]
143
167
}
144
- } )
145
- ) ;
168
+ } ) ,
169
+ openFile1Again : session => session . executeCommandSeq < protocol . UpdateOpenRequest > ( {
170
+ command : protocol . CommandTypes . UpdateOpen ,
171
+ arguments : {
172
+ openFiles : [ {
173
+ file : commonFile1 . path ,
174
+ fileContent : commonFile1 . content
175
+ } ]
176
+ }
177
+ } ) ,
178
+ } ) ;
146
179
} ) ;
147
180
} ) ;
148
181
}
0 commit comments