Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-tymoshenko committed Mar 14, 2024
1 parent 08c9111 commit 7751d33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"homepage": "https://github.com/platformatic/tail-file-stream#readme",
"devDependencies": {
"@types/node": "^20.11.26",
"@matteo.collina/tspl": "^0.1.1",
"c8": "^9.1.0",
"standard": "^17.1.0",
"tsd": "^0.30.7"
Expand Down
21 changes: 21 additions & 0 deletions test/open.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,29 @@
const assert = require('node:assert')
const { test } = require('node:test')
const { join } = require('node:path')
const { tspl } = require('@matteo.collina/tspl')
const { createReadStream } = require('..')

test('should open a file', (t, done) => {
const { strictEqual, ok } = tspl(t, { plan: 2 })

const pathToFile = join(__dirname, 'files', 'test-file-1.txt')
const stream = createReadStream(pathToFile, { autoWatch: false })

stream.on('open', (fd) => {
strictEqual(typeof fd, 'number')
})

stream.on('ready', () => {
ok(true)
})

stream.on('data', () => {
stream.destroy()
done()
})
})

test('should fail to open a fail', (t, done) => {
const pathToFile = join(__dirname, 'files', 'test-file-wrong.txt')
const stream = createReadStream(pathToFile, { autoWatch: false })
Expand Down

0 comments on commit 7751d33

Please sign in to comment.