@@ -109,66 +109,67 @@ describe('protocol storage directory utilities', () => {
109
109
} )
110
110
111
111
describe ( 'parseProtocolDirs' , ( ) => {
112
- it ( 'reads and parses directories' , ( ) => {
112
+ it ( 'reads and parses directories' , async ( ) => {
113
113
const protocolsDir = makeEmptyDir ( )
114
-
115
114
const firstProtocolDirName = 'protocol_item_1'
116
115
const secondProtocolDirName = 'protocol_item_2'
117
-
118
116
const firstDirPath = path . join ( protocolsDir , firstProtocolDirName )
119
117
const secondDirPath = path . join ( protocolsDir , secondProtocolDirName )
120
118
121
- return Promise . all ( [
122
- fs . emptyDir ( path . join ( protocolsDir , firstProtocolDirName ) ) ,
123
- fs . emptyDir ( path . join ( protocolsDir , firstProtocolDirName , 'src' ) ) ,
124
- fs . createFile (
125
- path . join ( protocolsDir , firstProtocolDirName , 'src' , 'main.py' )
126
- ) ,
127
- fs . emptyDir ( path . join ( protocolsDir , firstProtocolDirName , 'analysis' ) ) ,
128
- fs . createFile (
129
- path . join (
130
- protocolsDir ,
131
- firstProtocolDirName ,
132
- 'analysis' ,
133
- 'fake_timestamp0.json'
134
- )
135
- ) ,
136
- fs . emptyDir ( path . join ( protocolsDir , secondProtocolDirName ) ) ,
137
- fs . emptyDir ( path . join ( protocolsDir , secondProtocolDirName , 'src' ) ) ,
138
- fs . createFile (
139
- path . join ( protocolsDir , secondProtocolDirName , 'src' , 'main.json' )
140
- ) ,
141
- fs . emptyDir ( path . join ( protocolsDir , secondProtocolDirName , 'analysis' ) ) ,
142
- fs . createFile (
143
- path . join (
144
- protocolsDir ,
145
- secondProtocolDirName ,
146
- 'analysis' ,
147
- 'fake_timestamp1.json'
148
- )
149
- ) ,
150
- ] ) . then ( ( ) => {
151
- return expect (
152
- parseProtocolDirs ( [ firstDirPath , secondDirPath ] )
153
- ) . resolves . toEqual ( [
154
- {
155
- dirPath : firstDirPath ,
156
- modified : expect . any ( Number ) ,
157
- srcFilePaths : [ path . join ( firstDirPath , 'src' , 'main.py' ) ] ,
158
- analysisFilePaths : [
159
- path . join ( firstDirPath , 'analysis' , 'fake_timestamp0.json' ) ,
160
- ] ,
161
- } ,
162
- {
163
- dirPath : secondDirPath ,
164
- modified : expect . any ( Number ) ,
165
- srcFilePaths : [ path . join ( secondDirPath , 'src' , 'main.json' ) ] ,
166
- analysisFilePaths : [
167
- path . join ( secondDirPath , 'analysis' , 'fake_timestamp1.json' ) ,
168
- ] ,
169
- } ,
170
- ] )
171
- } )
119
+ await fs . emptyDir ( path . join ( protocolsDir , firstProtocolDirName ) )
120
+ await fs . emptyDir ( path . join ( protocolsDir , firstProtocolDirName , 'src' ) )
121
+ await fs . emptyDir (
122
+ path . join ( protocolsDir , firstProtocolDirName , 'analysis' )
123
+ )
124
+ await fs . createFile (
125
+ path . join ( protocolsDir , firstProtocolDirName , 'src' , 'main.py' )
126
+ )
127
+ await fs . createFile (
128
+ path . join (
129
+ protocolsDir ,
130
+ firstProtocolDirName ,
131
+ 'analysis' ,
132
+ 'fake_timestamp0.json'
133
+ )
134
+ )
135
+
136
+ await fs . emptyDir ( path . join ( protocolsDir , secondProtocolDirName ) )
137
+ await fs . emptyDir ( path . join ( protocolsDir , secondProtocolDirName , 'src' ) )
138
+ await fs . emptyDir (
139
+ path . join ( protocolsDir , secondProtocolDirName , 'analysis' )
140
+ )
141
+ await fs . createFile (
142
+ path . join ( protocolsDir , secondProtocolDirName , 'src' , 'main.json' )
143
+ )
144
+ await fs . createFile (
145
+ path . join (
146
+ protocolsDir ,
147
+ secondProtocolDirName ,
148
+ 'analysis' ,
149
+ 'fake_timestamp1.json'
150
+ )
151
+ )
152
+
153
+ const result = await parseProtocolDirs ( [ firstDirPath , secondDirPath ] )
154
+
155
+ expect ( result ) . toEqual ( [
156
+ {
157
+ dirPath : firstDirPath ,
158
+ modified : expect . any ( Number ) ,
159
+ srcFilePaths : [ path . join ( firstDirPath , 'src' , 'main.py' ) ] ,
160
+ analysisFilePaths : [
161
+ path . join ( firstDirPath , 'analysis' , 'fake_timestamp0.json' ) ,
162
+ ] ,
163
+ } ,
164
+ {
165
+ dirPath : secondDirPath ,
166
+ modified : expect . any ( Number ) ,
167
+ srcFilePaths : [ path . join ( secondDirPath , 'src' , 'main.json' ) ] ,
168
+ analysisFilePaths : [
169
+ path . join ( secondDirPath , 'analysis' , 'fake_timestamp1.json' ) ,
170
+ ] ,
171
+ } ,
172
+ ] )
172
173
} )
173
174
} )
174
175
0 commit comments