Skip to content

Commit 4171e5f

Browse files
fix: making setFileContents run after getFileContents
Signed-off-by: Scott Schreckengaust <[email protected]>
1 parent bf17509 commit 4171e5f

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

tests/lib/file_system_tests.js

+30-33
Original file line numberDiff line numberDiff line change
@@ -174,48 +174,45 @@ describe('lib', () => {
174174
})
175175
})
176176

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', () => {
196178
const fs = new FileSystem(__dirname)
197-
const filePath = path.resolve(__dirname, 'text_file_for_test.txt')
198-
const contents = await realFs.promises.readFile(filePath)
199179

200180
it('should return undefined if the file does not exist', async () => {
201181
const actual = await fs.getFileContents('notAFile')
202182
expect(actual).to.equal(undefined)
203183
})
204184

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+
)
214192
})
215193

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+
})
219216
})
220217
})
221218

0 commit comments

Comments
 (0)