このブログに基づいて Facebook ログイン ディレクティブを作成しています。
app.directive('facebook', function($http) {
return {
restrict: 'A',
scope: true,
controller: function($scope, $attrs, $location) {
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
// ... the rest of the directive
この匿名関数を単体テストするにはどうすればよいですか? ドキュメントをモックしてもうまくいかないようです。