From 0688404adf7cddd89f8cb4d1b60c942d4500495b Mon Sep 17 00:00:00 2001 From: vishnu Date: Wed, 25 Mar 2020 16:33:27 -0700 Subject: [PATCH] fix: refactor to mark simulation.type as an optional field cr https://code.amazon.com/reviews/CR-22069953 --- lib/clients/smapi-client/resources/test.js | 9 +++++--- test/unit/commands/dialog/index-test.js | 25 ++++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/clients/smapi-client/resources/test.js b/lib/clients/smapi-client/resources/test.js index f0f0f4a5..eff88ccf 100644 --- a/lib/clients/smapi-client/resources/test.js +++ b/lib/clients/smapi-client/resources/test.js @@ -31,9 +31,6 @@ module.exports = (smapiHandle) => { }, device: { locale - }, - simulation: { - type: simulationType } }; if (newSession) { @@ -41,6 +38,12 @@ module.exports = (smapiHandle) => { mode: 'FORCE_NEW_SESSION' }; } + + if (simulationType) { + payload.simulation = { + type: simulationType + }; + } smapiHandle( CONSTANTS.SMAPI.API_NAME.SIMULATE_SKILL, CONSTANTS.HTTP_REQUEST.VERB.POST, diff --git a/test/unit/commands/dialog/index-test.js b/test/unit/commands/dialog/index-test.js index d3bd154a..a34d45b8 100644 --- a/test/unit/commands/dialog/index-test.js +++ b/test/unit/commands/dialog/index-test.js @@ -223,24 +223,27 @@ describe('Commands Dialog test - command class test', () => { }); }); - it('| returns valid config with default simulation type', () => { + it('| returns valid config with default simulation type', (done) => { // setup const TEST_CMD_WITH_VALUES = { stage: '', replay: DIALOG_REPLAY_FILE_JSON_PATH, }; sinon.stub(profileHelper, 'runtimeProfile').returns(TEST_PROFILE); + sinon.stub(httpClient, 'request').yields(null, { statusCode: 200, body: { manifest } }); // call - const config = instance._getDialogConfig(TEST_CMD_WITH_VALUES); - // verify - expect(config.debug).equal(false); - expect(config.locale).equal('en-US'); - expect(config.profile).equal('default'); - expect(config.replay).equal(DIALOG_REPLAY_FILE_JSON_PATH); - expect(config.skillId).equal('amzn1.ask.skill.1234567890'); - expect(config.stage).equal('development'); - expect(config.simulationType).equal('DEFAULT'); - expect(config.userInputs).deep.equal(['hello', 'world']); + instance._getDialogConfig(TEST_CMD_WITH_VALUES, (err, config) => { + // verify + expect(config.debug).equal(false); + expect(config.locale).equal('en-US'); + expect(config.profile).equal('default'); + expect(config.replay).equal(DIALOG_REPLAY_FILE_JSON_PATH); + expect(config.skillId).equal('amzn1.ask.skill.1234567890'); + expect(config.stage).equal('development'); + expect(config.simulationType).equal('DEFAULT'); + expect(config.userInputs).deep.equal(['hello', 'world']); + done() + }); }); it('| returns error when initialization of DialogReplayFile fails', (done) => {