Skip to content

Commit

Permalink
fix: refactor to mark simulation.type as an optional field
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnu authored and RonWang committed Jul 19, 2021
1 parent 5cac3cf commit 0688404
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
9 changes: 6 additions & 3 deletions lib/clients/smapi-client/resources/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ module.exports = (smapiHandle) => {
},
device: {
locale
},
simulation: {
type: simulationType
}
};
if (newSession) {
payload.session = {
mode: 'FORCE_NEW_SESSION'
};
}

if (simulationType) {
payload.simulation = {
type: simulationType
};
}
smapiHandle(
CONSTANTS.SMAPI.API_NAME.SIMULATE_SKILL,
CONSTANTS.HTTP_REQUEST.VERB.POST,
Expand Down
25 changes: 14 additions & 11 deletions test/unit/commands/dialog/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 0688404

Please sign in to comment.