Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Test limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Montano committed Apr 29, 2022
1 parent 1752f5a commit a8a08b2
Showing 1 changed file with 60 additions and 3 deletions.
63 changes: 60 additions & 3 deletions lambda/test/conversation/reportOutage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Report Outage Conversation Tests', () => {
expect(getResponse()[0][0]).toEqual('reportOutage.askForHouseNumber.misheard')
})

it('Sends machine to saying house number sends them to ask for phone', async () => {
it('Saying house number sends them to ask for phone', async () => {

handlerInput.requestEnvelope.request.intent.name = 'ANumber'
//1233 % 3 = 0 => No outage in your area
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Report Outage Conversation Tests', () => {
expect(getResponse()[0][0]).toEqual('reportOutage.letYouKnowWOutageReport.confirm')
})

it('Sends machine to calling API when getting phone number', async () => {
it('check misheard on let you know with outage', async () => {

handlerInput.requestEnvelope.request.intent.name = 'ANumber'
setSlots(defaultNumberIntent('10').slots);
Expand Down Expand Up @@ -308,7 +308,64 @@ describe('Report Outage Conversation Tests', () => {

})


it('test limit on number misunderstandings', async () => {
handlerInput.requestEnvelope.request.intent.name = 'ReportOutage'
await run(handlerInput)

handlerInput.requestEnvelope.request.intent.name = 'APhoneNumber'
setSlots(defaultPhoneNumberIntent('3143225555').slots);
clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('askForHouseNumber')
expect(getResponse()[0][0]).toEqual('reportOutage.askForHouseNumber.misheard')

clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('askForHouseNumber')
expect(getResponse()[0][0]).toEqual('reportOutage.askForHouseNumber.misheard')

clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('askForHouseNumber')
expect(getResponse()[0][0]).toEqual('reportOutage.askForHouseNumber.misheard')

clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('askForHouseNumber')
expect(getResponse()[0][0]).toEqual('reportOutage.askForHouseNumber.misheard')

clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('resume')
expect(getResponse()[0][0]).toEqual('home.reEngage')

})

it('test limit on phone number misunderstandings', async () => {
handlerInput.requestEnvelope.request.intent.name = 'ReportOutage'
await run(handlerInput)

handlerInput.requestEnvelope.request.intent.name = 'ANumber'
setSlots(defaultNumberIntent(1234).slots); //There's an outage
await run(handlerInput)

handlerInput.requestEnvelope.request.intent.name = 'YesNoIntent'
setSlots(defaultYesNoIntent('yes').slots);
clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('askForTelephoneNumber')
expect(getResponse()[0][0]).toEqual('reportOutage.askForTelephoneNumber.misheard')

await run(handlerInput)
await run(handlerInput)
await run(handlerInput)

clearResponseMocks()
await run(handlerInput)
expect(getMockState().machineState).toEqual('resume')
expect(getResponse()[0][0]).toEqual('home.reEngage')

})

it('gives the generic error response on errors (error)', async () => {
handlerInput.attributesManager.setSessionAttributes({
Expand Down

0 comments on commit a8a08b2

Please sign in to comment.