SO question

Jasmine + Angular

by eitanp461

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>

<div ng-app="jbLocalStorage">
  123
  <hello></hello>
</div>

JavaScript

// Source
angular.module("jbLocalStorage", [])
.service("localStorageService", ["$window", function($window){

  this.has = function(key){
    console.log($window); //added to see what $window is referencing in unit test
    if ($window.localStorage.getItem(key) !== null){
      return true;
    } else {
      return false;
    }
  };
}])
.directive("hello", function() {
  return {
    template: "<h1>Hello {{::name}}</h1>"
  }
})
;