VividCortex / angular-recaptcha

AngularJS directive to add a reCaptcha widget to your form
http://vividcortex.github.io/angular-recaptcha/
MIT License
496 stars 257 forks source link

querySelectorAll is available in document but not in $document #53

Closed mtrias closed 9 years ago

mtrias commented 9 years ago

Hey guys, not sure why that line was written that way, here’s how i think it could be improved.

querySelectorAll is not available in $document.

Closes #54

TheSharpieOne commented 9 years ago

It is at $document[0].querySelectorAll, sorry about that. But using $document to get to the real document (which is what is at index 0) allows to better/easier testing.

This will allow someone to mock $document and inject it. something like:

  beforeEach(module(function($provide){
    var $doc = [{
      querySelectorAll: someSpyOrWhatever
    }];

    $provide.value('$document',$doc);
  }));