From 3cf00e0fc3ee78496c1ae954b9eb548dee3667b0 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 26 Dec 2024 12:09:14 -0600 Subject: [PATCH] Add some tests --- packages/stream/lib/index.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/stream/lib/index.test.ts b/packages/stream/lib/index.test.ts index 01201b53f..c221208a5 100644 --- a/packages/stream/lib/index.test.ts +++ b/packages/stream/lib/index.test.ts @@ -791,6 +791,26 @@ describe('SerialPort', () => { }) }) }) + + describe('#destroy', () => { + it('calls close', done => { + const port = new SerialPortStream(openOpts) + port.on('close', () => done()) + port.destroy() + }) + + it("doesn't open after destroy", done => { + const port = new SerialPortStream(openOpts) + port.on('open', () => { + port.destroy() + assert.isTrue(port.destroyed) + port.open(err => { + assert.instanceOf(err, Error) + done() + }) + }) + }) + }) }) describe('reading data', () => {