import assert from 'assert'; import { Response, Client } from '../lib/rest/client'; import { PlivoGenericResponse } from '../lib/base.js'; let client = new Client('sampleid', 'sammpletoken', 'sampleproxy'); describe('SsmlInterface', function () { it('Ssml - Invalid SSML XML Structure', function (done) { let response = new Response(); // Invalid speak body let speak_body = ' Here is a number read \ as a cardinal number: \ read. \ Here is a word spelled out: \ hello.'; // response.addSpeak(speak_body, { language: 'Spanish-Castilian', voice: 'Polly.*' }); response.addSpeak(speak_body, { language: 'Spanish-Castilian', voice: 'Polly.Conchita' }).then((result) => { done(new Error("Invalid xml should be rejected and should throw error.")); }).catch((err) => { assert.equal('Invalid SSML xml structure. Content must be a valid xml.', err.message); done(); }); }); it('Ssml - Invalid SSML Tags', function (done) { let response = new Response(); // Invalid speak body let speak_body = ' Here is a number read \ as a cardinal number: \ read. \ Here is a word spelled out: \ hello.'; // response.addSpeak(speak_body, { language: 'Spanish-Castilian', voice: 'Polly.*' }); response.addSpeak(speak_body, { language: 'Spanish-Castilian', voice: 'Polly.Conchita' }).then((result) => { done(new Error("Invalid xml tags should be rejected and should throw error.")); }).catch((err) => { assert.equal('Ssml tag is not supported.', err.message); done(); }); }); it('Ssml - Invalid Language Validation', function (done) { let response = new Response(); // Invalid speak body let speak_body = ' Here is a number'; response.addSpeak(speak_body, { language: 'Spanish-Castilian1', voice: 'Polly.Conchita' }).then((result) => { done(new Error("Unsupported language `Spanish-Castilian1` should be rejected and should throw error.")); }).catch((err) => { assert.equal('Invalid language. Language `Spanish-Castilian1` is not supported.', err.message); done(); }); }); it('Ssml - Invalid Language-Voice Combination', function (done) { let response = new Response(); // Invalid speak body let speak_body = 'Here is a number'; response.addSpeak(speak_body, { language: 'Spanish-Castilian', voice: 'Polly.Maxim' }).then((result) => { done(new Error("Invalid language voice combination should be rejected")); }).catch((err) => { assert.equal(' voice ‘Polly.Maxim’ is not valid. Refer for list of supported voices.', err.message); done(); }); }); it('Ssml - Valid Language-Voice Combination', function (done) { let response = new Response(); // Invalid speak body let speak_body = 'Here is a number'; response.addSpeak(speak_body, { language: 'Spanish-Castilian', voice: 'Polly.Conchita' }).then((result) => { done(); }).catch((err) => { done('Validate Language Voice combination should be accepted.'); }); }); });