Skip to content

Commit

Permalink
test: Cover the case of a non-existent JSON data file (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabschurt authored Jun 14, 2023
1 parent 94b5e93 commit 75de935
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ describe('#src/data', () => {
)
})
})

it('returns an empty object if the data file does not exist', async () => {
await withTempDir(async (prefixWithTempDir) => {
const dirPath = prefixWithTempDir('src')

await mkdir(dirPath)

assert.deepStrictEqual(
await parseDataFromJsonFile(withDir(dirPath), ifPathExists, readFile, parseJson),
{}
)
})
})
})

describe('parseDataFromEnv()', () => {
Expand Down

0 comments on commit 75de935

Please sign in to comment.