@@ -236,7 +236,7 @@ module.exports = {
236
236
// testOp(browser, "OR", "test input", "test_output");
237
237
// testOp(browser, "Object Identifier to Hex", "test input", "test_output");
238
238
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 ) ;
240
240
// testOp(browser, "PEM to Hex", "test input", "test_output");
241
241
// testOp(browser, "PGP Decrypt", "test input", "test_output");
242
242
// testOp(browser, "PGP Decrypt and Verify", "test input", "test_output");
@@ -408,7 +408,7 @@ module.exports = {
408
408
* @param {Browser } browser - Nightwatch client
409
409
* @param {string|Array<string> } opName - name of operation to be tested, array for multiple ops
410
410
* @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
412
412
*/
413
413
function bakeOp ( browser , opName , input , args = [ ] ) {
414
414
browser . perform ( function ( ) {
@@ -425,8 +425,8 @@ function bakeOp(browser, opName, input, args=[]) {
425
425
* @param {Browser } browser - Nightwatch client
426
426
* @param {string|Array<string> } opName - name of operation to be tested, array for multiple ops
427
427
* @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
430
430
*/
431
431
function testOp ( browser , opName , input , output , args = [ ] ) {
432
432
bakeOp ( browser , opName , input , args ) ;
@@ -440,8 +440,8 @@ function testOp(browser, opName, input, output, args=[]) {
440
440
* @param {string|Array<string> } opName - name of operation to be tested array for multiple ops
441
441
* @param {string } input - input text
442
442
* @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
445
445
*/
446
446
function testOpHtml ( browser , opName , input , cssSelector , output , args = [ ] ) {
447
447
bakeOp ( browser , opName , input , args ) ;
@@ -459,9 +459,9 @@ function testOpHtml(browser, opName, input, cssSelector, output, args=[]) {
459
459
* @param {Browser } browser - Nightwatch client
460
460
* @param {string|Array<string> } opName - name of operation to be tested array for multiple ops
461
461
* @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
463
463
*/
464
- function testOpImage ( browser , opName , filename , args ) {
464
+ function testOpImage ( browser , opName , filename , args = [ ] ) {
465
465
browser . perform ( function ( ) {
466
466
console . log ( `Current test: ${ opName } ` ) ;
467
467
} ) ;
@@ -481,11 +481,12 @@ function testOpImage(browser, opName, filename, args) {
481
481
* @param {Browser } browser - Nightwatch client
482
482
* @param {string|Array<string> } opName - name of operation to be tested array for multiple ops
483
483
* @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
487
488
*/
488
- function testOpFile ( browser , opName , filename , cssSelector , output , args ) {
489
+ function testOpFile ( browser , opName , filename , cssSelector , output , args = [ ] , waitWindow = 1000 ) {
489
490
browser . perform ( function ( ) {
490
491
console . log ( `Current test: ${ opName } ` ) ;
491
492
} ) ;
@@ -494,9 +495,14 @@ function testOpFile(browser, opName, filename, cssSelector, output, args) {
494
495
browser . pause ( 100 ) . waitForElementVisible ( "#stale-indicator" , 5000 ) ;
495
496
utils . bake ( browser ) ;
496
497
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
498
503
browser . expect . element ( "#output-html " + cssSelector ) . text . that . equals ( output ) ;
499
504
} else if ( output instanceof RegExp ) {
505
+ // HTML output - RegEx match
500
506
browser . expect . element ( "#output-html " + cssSelector ) . text . that . matches ( output ) ;
501
507
}
502
508
}
0 commit comments