Skip to content

Commit 3cf4bc3

Browse files
fix: update atomic-json test assertions
1 parent 9fc317e commit 3cf4bc3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

backend/src/utils/atomic-json.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
22
import { readJsonSafe, writeJsonAtomic, withFileLock } from './atomic-json'
33
import { join } from 'node:path'
4-
import { mkdtemp, rm } from 'node:fs/promises'
4+
import { mkdtemp, rm, writeFile, readFile } from 'node:fs/promises'
55
import { tmpdir } from 'node:os'
66

77
describe('atomic-json', () => {
@@ -24,7 +24,7 @@ describe('atomic-json', () => {
2424

2525
it('returns fallback when file contains invalid JSON and logs a warning', async () => {
2626
const filePath = join(tmpDir, 'invalid.json')
27-
await Bun.write(filePath, '{ invalid json }')
27+
await writeFile(filePath, '{ invalid json }', 'utf8')
2828
const fallback = { foo: 'bar' }
2929
const result = await readJsonSafe(filePath, fallback)
3030
expect(result).toEqual(fallback)
@@ -33,7 +33,7 @@ describe('atomic-json', () => {
3333
it('returns parsed value when file contains valid JSON', async () => {
3434
const filePath = join(tmpDir, 'valid.json')
3535
const data = { foo: 'bar', nested: { value: 42 } }
36-
await Bun.write(filePath, JSON.stringify(data))
36+
await writeFile(filePath, JSON.stringify(data), 'utf8')
3737
const result = await readJsonSafe(filePath, { fallback: true })
3838
expect(result).toEqual(data)
3939
})
@@ -44,7 +44,7 @@ describe('atomic-json', () => {
4444
const filePath = join(tmpDir, 'output.json')
4545
const data = { test: 'value', number: 123 }
4646
await writeJsonAtomic(filePath, data)
47-
const content = await Bun.file(filePath).text()
47+
const content = await readFile(filePath, 'utf8')
4848
const parsed = JSON.parse(content)
4949
expect(parsed).toEqual(data)
5050
})

0 commit comments

Comments
 (0)