WWW-Mechanize-Chrome-DOMops

 view release on metacpan or  search on metacpan

t/500-domops_find.t  view on Meta::CPAN

		ok(exists($ret->{'cb-results'}->{$acbname}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (executed JS in '$js_outfile_tmp...
		ok(defined($ret->{'cb-results'}->{$acbname}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is defined.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (executed JS ...
		is(ref($ret->{'cb-results'}->{$acbname}), 'ARRAY', 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (execut...

		# and now under it we must have an array for each function callback we declared
		# and that array must have a size of as many html elements were returned
		# and each item of the array must contain keys 'result' and 'name' (which is the func name declared)
		is(scalar(@{$ret->{'cb-results'}->{$acbname}}), scalar(@{$TV}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as ther...
		for(my $i=scalar(@{$ret->{'cb-results'}->{$acbname}});$i-->0;){
			my $ares1 = $ret->{'cb-results'}->{$acbname}->[$i];
			my $funcdata = $TV->[$i];
			if( $acbname eq 'find-cb-on-matched' ){
				is(scalar(@$ares1), scalar(@{$found->{'first-level'}}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as the HTML e...
			} else {
				is(scalar(@$ares1), scalar(@{$found->{'all-levels'}}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as the HTML el...
			}
			for my $ares2 (@$ares1){
				is($ares2->{'name'}, $funcdata->{'name'}, 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and verified function name it is as it was declared '".$funcdata->{'name'}."'.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (executed ...
				is($ares2->{'result'}, 1, 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned result is '1'.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (executed JS in '$js_outfile_tmp') : failed, above is what it was returned fr...
			}
		}
	}
}

diag "temp dir: $tmpdir ..." if exists($ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}) && $ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}>0;

# END
done_testing();

t/600-domops_zap.t  view on Meta::CPAN

		# domops_zap() adds one more callback under 'find-cb-on-matched' named '_thezapper' and it is the last in sequence
		if( $acbname eq 'find-cb-on-matched' ){
			is(scalar(@{$ret->{'cb-results'}->{$acbname}}), 1+scalar(@{$TV}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as t...
		} else {
			# this does not contain _thezapper
			is(scalar(@{$ret->{'cb-results'}->{$acbname}}), scalar(@{$TV}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as the...
		}
		# we make a special case for the _thezapper from the tests (it is the last)
		for(my $i=scalar(@{$ret->{'cb-results'}->{$acbname}});$i-->0;){
			my $ares1 = $ret->{'cb-results'}->{$acbname}->[$i];
			my $funcdata = (($acbname eq 'find-cb-on-matched') && (($i+1) == scalar(@{$ret->{'cb-results'}->{$acbname}})))
				? {'name'=>'_thezapper'} : $TV->[$i]
			;
			if( $acbname eq 'find-cb-on-matched' ){
				is(scalar(@$ares1), scalar(@{$found->{'first-level'}}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as the HTML e...
			} else {
				is(scalar(@$ares1), scalar(@{$found->{'all-levels'}}), 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned value contains key 'cb-results'->$acbname and it is an ARRAY which has exactly as many items as the HTML el...
			}
			for my $ares2 (@$ares1){
				is($ares2->{'name'}, $funcdata->{'name'}, 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and verified function name it is as it was declared '".$funcdata->{'name'}."'.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (executed ...
				is($ares2->{'result'}, 1, 'domops_find()'." : test '${tk}' : called with a '${acbname}' callback and returned result is '1'.") or BAIL_OUT(perl2dump($ret)."test '${tk}' (executed JS in '$js_outfile_tmp') : failed above is what it was returned fro...
			}
		}
	}	
}

diag "temp dir: $tmpdir ..." if exists($ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}) && $ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}>0;

# END
done_testing();



( run in 0.634 second using v1.01-cache-2.11-cpan-454fe037f31 )