From c7d08020126228865249483738ef4eb835b370db Mon Sep 17 00:00:00 2001 From: Hannes Ljungberg Date: Wed, 13 Jun 2018 19:49:50 +0200 Subject: [PATCH] Add tests for scanner --- test/scanner.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/scanner.test.js b/test/scanner.test.js index c455904..de26670 100644 --- a/test/scanner.test.js +++ b/test/scanner.test.js @@ -166,4 +166,28 @@ describe("scanner", () => { nobleMock.emit("discover", peripheral); assert(eventSpy.calledWith(sinon.match.instanceOf(Error))); }); + + it("should log on scanStart", () => { + const spyDebugLogger = sinon.spy(mockLogger, "debug"); + new Scanner(mockLogger, "ABC"); + nobleMock.emit("scanStart"); + assert(spyDebugLogger.called); + spyDebugLogger.restore(); + }); + + it("should log on scanStop", () => { + const spyDebugLogger = sinon.spy(mockLogger, "debug"); + new Scanner(mockLogger, "ABC"); + nobleMock.emit("scanStop"); + assert(spyDebugLogger.called); + spyDebugLogger.restore(); + }); + + it("should log on warning", () => { + const spyInfoLogger = sinon.spy(mockLogger, "info"); + new Scanner(mockLogger, "ABC"); + nobleMock.emit("warning", "some warning"); + assert(spyInfoLogger.called); + spyInfoLogger.restore(); + }); });