import { Verb } from '../../../../../models/bxml/Verb'; import { Gather, GatherAttributes } from '../../../../../models/bxml/verbs/Gather'; import { PlayAudio } from '../../../../../models/bxml/verbs/PlayAudio'; import { SpeakSentence } from '../../../../../models/bxml/verbs/SpeakSentence'; describe('Gather', () => { const attributes: GatherAttributes = { gatherUrl: 'https://initial.com', gatherMethod: 'POST', gatherFallbackUrl: 'https://initial.com', gatherFallbackMethod: 'POST', username: 'initialUsername', password: 'initialPassword', fallbackUsername: 'initialFallbackUsername', fallbackPassword: 'initialFallbackPassword', tag: 'initialTag', terminatingDigits: '5', maxDigits: 5, interDigitTimeout: 5, firstDigitTimeout: 5, repeatCount: 5 }; const playAudio = new PlayAudio('https://audio.url/audio1.wav'); const speakSentence = new SpeakSentence('Holanodejs speak sentence SSML test'); test('should create a Gather Verb', () => { const gather = new Gather(attributes); const expected = ''; expect(gather).toBeInstanceOf(Gather); expect(gather).toBeInstanceOf(Verb); expect(gather.toBxml()).toBe(expected); }); test('should create a Gather Verb with nested PlayAudio and SpeakSentence', () => { let gather = new Gather(attributes, playAudio); const expected = 'https://audio.url/audio1.wav'; const expectedSingle = 'https://audio.url/audio1.wavHolanodejs speak sentence SSML test'; const expectedMultiple = 'https://audio.url/audio1.wavHolanodejs speak sentence SSML testHolanodejs speak sentence SSML testhttps://audio.url/audio1.wav'; expect(gather).toBeInstanceOf(Gather); expect(gather).toBeInstanceOf(Verb); expect(gather.toBxml()).toBe(expected); gather.addAudioVerbs(speakSentence); expect(gather.toBxml()).toBe(expectedSingle); gather.addAudioVerbs([speakSentence, playAudio]); expect(gather.toBxml()).toBe(expectedMultiple); }); test('should test the addAudioVerbs method when no verbs are initially nested', () => { const gather = new Gather(attributes); const expected = 'https://audio.url/audio1.wav'; gather.addAudioVerbs(playAudio); expect(gather.toBxml()).toBe(expected); }); });