UNPKG

ivr-tester

Version:

An automated testing framework for IVR call flows

37 lines (36 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StopTestRunnerWhenTestsComplete = void 0; /** Stops the test run when all the tests complete */ class StopTestRunnerWhenTestsComplete { constructor() { this.totalRunning = 0; this.totalSuccessful = 0; this.totalFailed = 0; } initialise(_, testRunner) { this.testRunner = testRunner; } testStarted(testSession) { this.totalRunning++; testSession.callFlowSession.on("allPromptsMatched", this.testSuccessful.bind(this)); testSession.callFlowSession.on("timeoutWaitingForMatch", this.testFailed.bind(this)); } testSuccessful() { this.totalSuccessful++; this.testCompleted(); } testFailed() { this.totalFailed++; this.testCompleted(); } testCompleted() { const totalCompletedTests = this.totalSuccessful + this.totalFailed; const allTestsCompleted = totalCompletedTests >= this.totalRunning; if (this.testRunner && allTestsCompleted) { const failed = this.totalFailed > 0; this.testRunner.stop(failed); } } } exports.StopTestRunnerWhenTestsComplete = StopTestRunnerWhenTestsComplete;