MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / $$TestabilityProvider

Function $$TestabilityProvider

lib/test/angular/1.8.0/angular.js:21484–21605  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

21482
21483/** @this */
21484function $$TestabilityProvider() {
21485 this.$get = ['$rootScope', '$browser', '$location',
21486 function($rootScope, $browser, $location) {
21487
21488 /**
21489 * @name $testability
21490 *
21491 * @description
21492 * The private $$testability service provides a collection of methods for use when debugging
21493 * or by automated test and debugging tools.
21494 */
21495 var testability = {};
21496
21497 /**
21498 * @name $$testability#findBindings
21499 *
21500 * @description
21501 * Returns an array of elements that are bound (via ng-bind or {{}})
21502 * to expressions matching the input.
21503 *
21504 * @param {Element} element The element root to search from.
21505 * @param {string} expression The binding expression to match.
21506 * @param {boolean} opt_exactMatch If true, only returns exact matches
21507 * for the expression. Filters and whitespace are ignored.
21508 */
21509 testability.findBindings = function(element, expression, opt_exactMatch) {
21510 var bindings = element.getElementsByClassName('ng-binding');
21511 var matches = [];
21512 forEach(bindings, function(binding) {
21513 var dataBinding = angular.element(binding).data('$binding');
21514 if (dataBinding) {
21515 forEach(dataBinding, function(bindingName) {
21516 if (opt_exactMatch) {
21517 var matcher = new RegExp('(^|\\s)' + escapeForRegexp(expression) + '(\\s|\\||$)');
21518 if (matcher.test(bindingName)) {
21519 matches.push(binding);
21520 }
21521 } else {
21522 if (bindingName.indexOf(expression) !== -1) {
21523 matches.push(binding);
21524 }
21525 }
21526 });
21527 }
21528 });
21529 return matches;
21530 };
21531
21532 /**
21533 * @name $$testability#findModels
21534 *
21535 * @description
21536 * Returns an array of elements that are two-way found via ng-model to
21537 * expressions matching the input.
21538 *
21539 * @param {Element} element The element root to search from.
21540 * @param {string} expression The model expression to match.
21541 * @param {boolean} opt_exactMatch If true, only returns exact matches

Callers

nothing calls this directly

Calls 2

forEachFunction · 0.70
escapeForRegexpFunction · 0.70

Tested by

no test coverage detected