   describe "initializing an anchor", ->
     it "should register with the service", ->
       element = angular.element "<div mac-scroll-spy-anchor id='test-anchor'></div>"
-      angular.element("body").append element
+      angular.element(document.body).append element
       $compile(element) $rootScope
       $rootScope.$digest()
 


    it "should update anchor on refresh-scroll-spy event", ->
      element = angular.element("<div mac-scroll-spy-anchor id='test'></div>")
      angular.element("body").append element
      $compile(element) $rootScope

      origTop = element.offset().top
      element.css "margin-top", 200

      $rootScope.$broadcast "refresh-scroll-spy"

      expect(origTop).not.toBe scrollspy.registered[0].top


  describe "scrollspy service", ->
    it "should register an anchor", ->
      element = angular.element("<div></div>")
      angular.element(document.body).append element
      scrollspy.register "test", element

      expect(scrollspy.registered.length).toBe 1

    it "should unregister an anchor", ->
      element = angular.element("<div></div>")
      angular.element(document.body).append element
      scrollspy.register "test", element
      scrollspy.unregister "test"

