@@ -174,48 +174,45 @@ describe('lib', () => {
174
174
} )
175
175
} )
176
176
177
- // describe('getFileContents', () => {
178
- // const fs = new FileSystem(__dirname)
179
-
180
- // it('should return undefined if the file does not exist', async () => {
181
- // const actual = await fs.getFileContents('notAFile')
182
- // expect(actual).to.equal(undefined)
183
- // })
184
-
185
- // it('should return the contents of a file', async () => {
186
- // const raw = await fs.getFileContents('text_file_for_test.txt')
187
- // // replace newlines to prevent compatibility issues
188
- // const actual = raw.replace(/\r/g, '')
189
- // expect(actual).to.equal(
190
- // 'The contents of this file\nwill be monitored for quality assurance purposes\n'
191
- // )
192
- // })
193
- // })
194
-
195
- describe ( 'setFileContents' , async ( ) => {
177
+ describe ( 'getFileContents' , ( ) => {
196
178
const fs = new FileSystem ( __dirname )
197
- const filePath = path . resolve ( __dirname , 'text_file_for_test.txt' )
198
- const contents = await realFs . promises . readFile ( filePath )
199
179
200
180
it ( 'should return undefined if the file does not exist' , async ( ) => {
201
181
const actual = await fs . getFileContents ( 'notAFile' )
202
182
expect ( actual ) . to . equal ( undefined )
203
183
} )
204
184
205
- // it('should throw an error if the file does not exist', async () => {
206
- // expect(() => fs.getFileContents('notAFile')).to.throw()
207
- // })
208
- it ( 'should change the contents of a file' , async ( ) => {
209
- const expected = 'somefilecontents\nmorecontents\n'
210
- await fs . setFileContents ( 'text_file_for_test.txt' , expected )
211
- const fileContents = await realFs . promises . readFile ( filePath , 'utf8' )
212
- const realFileContents = fileContents . replace ( / \r / g, '' )
213
- expect ( realFileContents ) . to . equal ( expected )
185
+ it ( 'should return the contents of a file' , async ( ) => {
186
+ const raw = await fs . getFileContents ( 'text_file_for_test.txt' )
187
+ // replace newlines to prevent compatibility issues
188
+ const actual = raw . replace ( / \r / g, '' )
189
+ expect ( actual ) . to . equal (
190
+ 'The contents of this file\nwill be monitored for quality assurance purposes\n'
191
+ )
214
192
} )
215
193
216
- after ( async ( ) => {
217
- // reset the file contents
218
- await realFs . promises . writeFile ( filePath , contents )
194
+ describe ( 'setFileContents' , async ( ) => {
195
+ const fs = new FileSystem ( __dirname )
196
+ const filePath = path . resolve ( __dirname , 'text_file_for_test.txt' )
197
+ const contents = await realFs . promises . readFile ( filePath )
198
+
199
+ it ( 'should return undefined if the file does not exist' , async ( ) => {
200
+ const actual = await fs . getFileContents ( 'notAFile' )
201
+ expect ( actual ) . to . equal ( undefined )
202
+ } )
203
+
204
+ it ( 'should change the contents of a file' , async ( ) => {
205
+ const expected = 'somefilecontents\nmorecontents\n'
206
+ await fs . setFileContents ( 'text_file_for_test.txt' , expected )
207
+ const fileContents = await realFs . promises . readFile ( filePath , 'utf8' )
208
+ const realFileContents = fileContents . replace ( / \r / g, '' )
209
+ expect ( realFileContents ) . to . equal ( expected )
210
+ } )
211
+
212
+ after ( async ( ) => {
213
+ // reset the file contents
214
+ await realFs . promises . writeFile ( filePath , contents )
215
+ } )
219
216
} )
220
217
} )
221
218
0 commit comments