alexa-message-builder
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -101,2 +101,76 @@ 'use strict' | ||
addDialogDelegate(updatedIntent) { | ||
if (!this.template.response.directives) { | ||
this.template.response.directives = [] | ||
} | ||
const directive = { | ||
type: 'Dialog.Delegate' | ||
} | ||
if (updatedIntent) { | ||
directive.updatedIntent = updatedIntent | ||
} | ||
this.template.response.directives.push(directive) | ||
return this | ||
} | ||
addDialogElicitSlot(slot, updatedIntent) { | ||
if (!this.template.response.directives) { | ||
this.template.response.directives = [] | ||
} | ||
const directive = { | ||
type: 'Dialog.ElicitSlot', | ||
slotToElicit: slot | ||
} | ||
if (updatedIntent) { | ||
directive.updatedIntent = updatedIntent | ||
} | ||
this.template.response.directives.push(directive) | ||
return this | ||
} | ||
addDialogConfirmSlot(slot, updatedIntent) { | ||
if (!this.template.response.directives) { | ||
this.template.response.directives = [] | ||
} | ||
const directive = { | ||
type: 'Dialog.ConfirmSlot', | ||
slotToConfirm: slot | ||
} | ||
if (updatedIntent) { | ||
directive.updatedIntent = updatedIntent | ||
} | ||
this.template.response.directives.push(directive) | ||
return this | ||
} | ||
addDialogConfirmIntent(updatedIntent) { | ||
if (!this.template.response.directives) { | ||
this.template.response.directives = [] | ||
} | ||
const directive = { | ||
type: 'Dialog.ConfirmIntent' | ||
} | ||
if (updatedIntent) { | ||
directive.updatedIntent = updatedIntent | ||
} | ||
this.template.response.directives.push(directive) | ||
return this | ||
} | ||
keepSession() { | ||
@@ -108,2 +182,3 @@ this.template.response.shouldEndSession = false | ||
get() { | ||
@@ -110,0 +185,0 @@ return this.template |
{ | ||
"name": "alexa-message-builder", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Simple builder for Alexa replies.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -242,2 +242,104 @@ /* global describe, it, expect */ | ||
}) | ||
describe('dialog directives', () => { | ||
const intent = { | ||
name: 'TestIntent', | ||
confirmationStatus: 'None', | ||
slots: { } | ||
} | ||
describe('addDialogDelegate', () => { | ||
it('should be a function', () => { | ||
const message = new AlexaMessageBuilder() | ||
expect(typeof message.addDialogDelegate).toBe('function') | ||
}) | ||
it('should add a delegate directive', () => { | ||
const message = new AlexaMessageBuilder().addDialogDelegate(intent) | ||
expect(message.get()).toEqual({ | ||
version: '1.0', | ||
response: { | ||
shouldEndSession: true, | ||
directives: [ | ||
{ | ||
type: 'Dialog.Delegate', | ||
updatedIntent: intent | ||
} | ||
] | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('addDialogElicitSlot', () => { | ||
it('should be a function', () => { | ||
const message = new AlexaMessageBuilder() | ||
expect(typeof message.addDialogElicitSlot).toBe('function') | ||
}) | ||
it('should add a elicit slot directive', () => { | ||
const message = new AlexaMessageBuilder().addDialogElicitSlot('slotname', intent) | ||
expect(message.get()).toEqual({ | ||
version: '1.0', | ||
response: { | ||
shouldEndSession: true, | ||
directives: [ | ||
{ | ||
type: 'Dialog.ElicitSlot', | ||
slotToElicit: 'slotname', | ||
updatedIntent: intent | ||
} | ||
] | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('addDialogConfirmSlot', () => { | ||
it('should be a function', () => { | ||
const message = new AlexaMessageBuilder() | ||
expect(typeof message.addDialogConfirmSlot).toBe('function') | ||
}) | ||
it('should add a confirm slot directive', () => { | ||
const message = new AlexaMessageBuilder().addDialogConfirmSlot('slotname', intent) | ||
expect(message.get()).toEqual({ | ||
version: '1.0', | ||
response: { | ||
shouldEndSession: true, | ||
directives: [ | ||
{ | ||
type: 'Dialog.ConfirmSlot', | ||
slotToConfirm: 'slotname', | ||
updatedIntent: intent | ||
} | ||
] | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('addDialogConfirmIntent', () => { | ||
it('should be a function', () => { | ||
const message = new AlexaMessageBuilder() | ||
expect(typeof message.addDialogConfirmIntent).toBe('function') | ||
}) | ||
it('should add a delegate directive', () => { | ||
const message = new AlexaMessageBuilder().addDialogConfirmIntent(intent) | ||
expect(message.get()).toEqual({ | ||
version: '1.0', | ||
response: { | ||
shouldEndSession: true, | ||
directives: [ | ||
{ | ||
type: 'Dialog.ConfirmIntent', | ||
updatedIntent: intent | ||
} | ||
] | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29441
490