From 9ffde98f28d2b895b278a06cefece55f7209ff2c Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Wed, 19 Jul 2017 10:39:54 +0200 Subject: [PATCH] Add tests --- lib/plugins/platform/platform.test.js | 15 +++++++++++++++ .../selectors/selectServicePublish.test.js | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 lib/utils/selectors/selectServicePublish.test.js diff --git a/lib/plugins/platform/platform.test.js b/lib/plugins/platform/platform.test.js index 2f9c4a2fc..fe91d210a 100644 --- a/lib/plugins/platform/platform.test.js +++ b/lib/plugins/platform/platform.test.js @@ -147,5 +147,20 @@ describe('Platform', () => { expect(console.log.calledWithExactly(url)).to.be.equal(true); }); }); + + it('should skip publishing if user opted out via "publish" config', () => { + platform.serverless.service.service = 'new-service-2'; + platform.serverless.service.serviceObject = { + name: 'new-service-2', + publish: false, + }; + + return platform.publishService().then(() => { + expect(getAuthTokenStub.calledOnce).to.be.equal(true); + expect(getAccountIdStub.calledOnce).to.be.equal(false); + expect(endpointsRequestStub.calledOnce).to.be.equal(false); + expect(publishServiceRequestStub.calledOnce).to.be.equal(false); + }); + }); }); }); diff --git a/lib/utils/selectors/selectServicePublish.test.js b/lib/utils/selectors/selectServicePublish.test.js new file mode 100644 index 000000000..b762eaead --- /dev/null +++ b/lib/utils/selectors/selectServicePublish.test.js @@ -0,0 +1,18 @@ +'use strict'; + +const expect = require('chai').expect; +const selectServicePublish = require('./selectServicePublish'); + +describe('#selectServicePublish()', () => { + it('should return the publish value of the service object', () => { + const service = { + serviceObject: { + publish: true, + }, + }; + + const result = selectServicePublish(service); + + expect(result).to.equal(true); + }); +});