From 9b21292b44e979b2edb423c4e02ce07a8b7f9e58 Mon Sep 17 00:00:00 2001 From: Christopher Hoskin Date: Tue, 11 Aug 2020 09:53:29 +0100 Subject: [PATCH] Ensure fetchResponse.text is a string in sinon stub --- libraries/logger/test/unit/loggingManagerTests.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/logger/test/unit/loggingManagerTests.js b/libraries/logger/test/unit/loggingManagerTests.js index c543b6321b..5f8c3a9d81 100644 --- a/libraries/logger/test/unit/loggingManagerTests.js +++ b/libraries/logger/test/unit/loggingManagerTests.js @@ -316,7 +316,7 @@ describe('LoggingManager', function () { describe('when read errors', function () { beforeEach(async function () { - this.Fs.promises.readFile.throws(new Error('error')) + this.Fs.promises.readFile.throws(new Error('test read error')) this.logger.getTracingEndTime = this.logger.getTracingEndTimeFile await this.logger.checkLogLevel() }) @@ -330,7 +330,7 @@ describe('LoggingManager', function () { describe('when the file is empty', function () { beforeEach(async function () { - this.Fs.promises.readFile.yields(null, '') + this.Fs.promises.readFile.returns('') this.logger.getTracingEndTime = this.logger.getTracingEndTimeFile await this.logger.checkLogLevel() }) @@ -344,7 +344,7 @@ describe('LoggingManager', function () { describe('when time value returned that is less than current time', function () { beforeEach(async function () { - this.Fs.promises.readFile.yields(null, '1') + this.Fs.promises.readFile.returns('1') this.logger.getTracingEndTime = this.logger.getTracingEndTimeFile await this.logger.checkLogLevel() }) @@ -453,7 +453,7 @@ describe('LoggingManager', function () { describe('when level is already set', function() { beforeEach(async function() { this.bunyanLogger.level.returns(10) - this.fetchResponse.text = sinon.stub().resolves(this.start + 1000) + this.fetchResponse.text = sinon.stub().resolves((this.start + 1000).toString()) this.logger.getTracingEndTime = this.logger.getTracingEndTimeMetadata await this.logger.checkLogLevel() @@ -469,7 +469,7 @@ describe('LoggingManager', function () { describe('when level is not already set', function() { beforeEach(async function() { this.bunyanLogger.level.returns(20) - this.fetchResponse.text = sinon.stub().resolves(this.start + 1000) + this.fetchResponse.text = sinon.stub().resolves((this.start + 1000).toString()) this.Fetch.fetch = sinon.stub().resolves(this.fetchResponse) this.logger.getTracingEndTime = this.logger.getTracingEndTimeMetadata