-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Accenture/actions-definition
Actions definition
- Loading branch information
Showing
5 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
const expect = require('chai').expect; | ||
const app = require('./test-apps/contacts-app'); | ||
const alexia = require('..'); | ||
|
||
describe('action app handler', () => { | ||
|
||
it('should handle OpenContactList -> NewContact and return correct outputSpeech', () => { | ||
const request = alexia.createIntentRequest('NewContact', null, {previousIntent: 'OpenContactList'}); | ||
app.handle(request, (response) => { | ||
expect(response.response.outputSpeech.text).to.equal('Please insert value for name or phone number of contact.'); | ||
}); | ||
}); | ||
|
||
it('should handle NewContact -> SetName and return correct outputSpeech', () => { | ||
const request = alexia.createIntentRequest('SetName', null, {previousIntent: 'NewContact'}); | ||
app.handle(request, (response) => { | ||
expect(response.response.outputSpeech.text).to.equal('Name was saved.'); | ||
}); | ||
}); | ||
|
||
it('should handle SetName -> CloseContactList and return correct outputSpeech', () => { | ||
const request = alexia.createIntentRequest('CloseContactList', null, {previousIntent: 'SetName'}); | ||
app.handle(request, (response) => { | ||
expect(response.response.outputSpeech.text).to.equal('See you next time.'); | ||
}); | ||
}); | ||
|
||
it('should not handle OpenContactList -> SetName and return correct outputSpeech', () => { | ||
const request = alexia.createIntentRequest('SetName', null, {previousIntent: 'OpenContactList'}); | ||
app.handle(request, (response) => { | ||
expect(response.response.outputSpeech.text).to.equal('Sorry, your command is invalid'); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// short app for testing action's transitions saved in arrays | ||
'use strict'; | ||
const alexia = require('../..'); | ||
const app = alexia.createApp('ContactsApp'); | ||
|
||
app.intent('OpenContactList', 'Open contact list', () => { | ||
return 'You can list your contacts, add new one or change already saved ones.'; | ||
}); | ||
|
||
app.intent('NewContact', 'Create new contact', () => { | ||
return 'Please insert value for name or phone number of contact.'; | ||
}); | ||
|
||
app.intent('ChangeContact', 'Change name for Glogo contact', () => { | ||
return 'Please insert new value for name or phone number.'; | ||
}); | ||
|
||
app.intent('SetName', 'Set name to Misyak', () => { | ||
return 'Name was saved.'; | ||
}); | ||
|
||
app.intent('SetNumber', 'Set number to {number:NUMBER}', () => { | ||
return 'Number was saved.'; | ||
}); | ||
|
||
app.intent('CloseContactList', 'Close contact list', () => { | ||
return 'See you next time.'; | ||
}); | ||
|
||
app.action({ | ||
from: 'OpenContactList', | ||
to: ['NewContact', 'ChangeContact'] | ||
}); | ||
|
||
app.action({ | ||
from: ['NewContact', 'ChangeContact'], | ||
to: ['SetName', 'SetNumber'] | ||
}); | ||
|
||
app.action({ | ||
from: ['NewContact', 'ChangeContact', 'SetName', 'SetNumber'], | ||
to: 'CloseContactList' | ||
}); | ||
|
||
module.exports = app; |