@@ -236,7 +236,7 @@ module.exports = {
236236 // testOp(browser, "OR", "test input", "test_output");
237237 // testOp(browser, "Object Identifier to Hex", "test input", "test_output");
238238 testOpHtml ( browser , "Offset checker" , "test input\n\nbest input" , ".hl5" , "est input" ) ;
239- // testOp (browser, "Optical Character Recognition", "test input", "test_output" );
239+ testOpFile ( browser , "Optical Character Recognition" , "files/testocr.png" , false , / T h i s i s a l o t o f 1 2 p o i n t t e x t t o t e s t t h e / , [ ] , 10000 ) ;
240240 // testOp(browser, "PEM to Hex", "test input", "test_output");
241241 // testOp(browser, "PGP Decrypt", "test input", "test_output");
242242 // testOp(browser, "PGP Decrypt and Verify", "test input", "test_output");
@@ -408,7 +408,7 @@ module.exports = {
408408 * @param {Browser } browser - Nightwatch client
409409 * @param {string|Array<string> } opName - name of operation to be tested, array for multiple ops
410410 * @param {string } input - input text for test
411- * @param {Array<string>|Array<Array<string>> } args - arguments, nested if multiple ops
411+ * @param {Array<string>|Array<Array<string>> } [ args=[]] - arguments, nested if multiple ops
412412 */
413413function bakeOp ( browser , opName , input , args = [ ] ) {
414414 browser . perform ( function ( ) {
@@ -425,8 +425,8 @@ function bakeOp(browser, opName, input, args=[]) {
425425 * @param {Browser } browser - Nightwatch client
426426 * @param {string|Array<string> } opName - name of operation to be tested, array for multiple ops
427427 * @param {string } input - input text
428- * @param {string } output - expected output
429- * @param {Array<string>|Array<Array<string>> } args - arguments, nested if multiple ops
428+ * @param {string|RegExp } output - expected output
429+ * @param {Array<string>|Array<Array<string>> } [ args=[]] - arguments, nested if multiple ops
430430 */
431431function testOp ( browser , opName , input , output , args = [ ] ) {
432432 bakeOp ( browser , opName , input , args ) ;
@@ -440,8 +440,8 @@ function testOp(browser, opName, input, output, args=[]) {
440440 * @param {string|Array<string> } opName - name of operation to be tested array for multiple ops
441441 * @param {string } input - input text
442442 * @param {string } cssSelector - CSS selector for HTML output
443- * @param {string } output - expected output
444- * @param {Array<string>|Array<Array<string>> } args - arguments, nested if multiple ops
443+ * @param {string|RegExp } output - expected output
444+ * @param {Array<string>|Array<Array<string>> } [ args=[]] - arguments, nested if multiple ops
445445 */
446446function testOpHtml ( browser , opName , input , cssSelector , output , args = [ ] ) {
447447 bakeOp ( browser , opName , input , args ) ;
@@ -459,9 +459,9 @@ function testOpHtml(browser, opName, input, cssSelector, output, args=[]) {
459459 * @param {Browser } browser - Nightwatch client
460460 * @param {string|Array<string> } opName - name of operation to be tested array for multiple ops
461461 * @param {string } filename - filename of image file from samples directory
462- * @param {Array<string>|Array<Array<string>> } args - arguments, nested if multiple ops
462+ * @param {Array<string>|Array<Array<string>> } [ args=[]] - arguments, nested if multiple ops
463463 */
464- function testOpImage ( browser , opName , filename , args ) {
464+ function testOpImage ( browser , opName , filename , args = [ ] ) {
465465 browser . perform ( function ( ) {
466466 console . log ( `Current test: ${ opName } ` ) ;
467467 } ) ;
@@ -481,11 +481,12 @@ function testOpImage(browser, opName, filename, args) {
481481 * @param {Browser } browser - Nightwatch client
482482 * @param {string|Array<string> } opName - name of operation to be tested array for multiple ops
483483 * @param {string } filename - filename of file from samples directory
484- * @param {string } cssSelector - CSS selector for HTML output
485- * @param {string } output - expected output
486- * @param {Array<string>|Array<Array<string>> } args - arguments, nested if multiple ops
484+ * @param {string|boolean } cssSelector - CSS selector for HTML output or false for normal text output
485+ * @param {string|RegExp } output - expected output
486+ * @param {Array<string>|Array<Array<string>> } [args=[]] - arguments, nested if multiple ops
487+ * @param {number } [waitWindow=1000] - The number of milliseconds to wait for the output to be correct
487488 */
488- function testOpFile ( browser , opName , filename , cssSelector , output , args ) {
489+ function testOpFile ( browser , opName , filename , cssSelector , output , args = [ ] , waitWindow = 1000 ) {
489490 browser . perform ( function ( ) {
490491 console . log ( `Current test: ${ opName } ` ) ;
491492 } ) ;
@@ -494,9 +495,14 @@ function testOpFile(browser, opName, filename, cssSelector, output, args) {
494495 browser . pause ( 100 ) . waitForElementVisible ( "#stale-indicator" , 5000 ) ;
495496 utils . bake ( browser ) ;
496497
497- if ( typeof output === "string" ) {
498+ if ( ! cssSelector ) {
499+ // Text output
500+ utils . expectOutput ( browser , output , true , waitWindow ) ;
501+ } else if ( typeof output === "string" ) {
502+ // HTML output - string match
498503 browser . expect . element ( "#output-html " + cssSelector ) . text . that . equals ( output ) ;
499504 } else if ( output instanceof RegExp ) {
505+ // HTML output - RegEx match
500506 browser . expect . element ( "#output-html " + cssSelector ) . text . that . matches ( output ) ;
501507 }
502508}
0 commit comments