Sha256: e977a29500cb4cc48cd29d84d55d6e2df7064540824abf2173afb8604bb17d32

Contents?: true

Size: 1.68 KB

Versions: 8

Compression:

Stored size: 1.68 KB

Contents

/*global describe, beforeEach, module, inject, it, spyOn, expect, $ */
describe('uiScrollfix', function () {
  'use strict';

  var scope, $compile, $window;
  beforeEach(module('ui.directives'));
  beforeEach(inject(function (_$rootScope_, _$compile_, _$window_) {
    scope = _$rootScope_.$new();
    $compile = _$compile_;
    $window = _$window_;
  }));

  describe('compiling this directive', function () {
    it('should bind to window "scroll" event with a ui-scrollfix namespace', function () {
      spyOn($.fn, 'on');
      $compile('<div ui-scrollfix="100"></div>')(scope);
      expect($.fn.on).toHaveBeenCalled();
      expect($.fn.on.mostRecentCall.args[0]).toBe('scroll.ui-scrollfix');
    });
  });
  describe('scrolling the window', function () {
    it('should add the ui-scrollfix class if the offset is greater than specified', function () {
      var element = $compile('<div ui-scrollfix="-100"></div>')(scope);
      $($window).trigger('scroll.ui-scrollfix');
      expect(element.hasClass('ui-scrollfix')).toBe(true);
    });
    it('should remove the ui-scrollfix class if the offset is less than specified (using absolute coord)', function () {
      var element = $compile('<div ui-scrollfix="100" class="ui-scrollfix"></div>')(scope);
      $($window).trigger('scroll.ui-scrollfix');
      expect(element.hasClass('ui-scrollfix')).toBe(false);

    });
    it('should remove the ui-scrollfix class if the offset is less than specified (using relative coord)', function () {
      var element = $compile('<div ui-scrollfix="+100" class="ui-scrollfix"></div>')(scope);
      $($window).trigger('scroll.ui-scrollfix');
      expect(element.hasClass('ui-scrollfix')).toBe(false);
    });
  });
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_record_survey_api-0.0.19 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.18 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.17 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.14 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.12 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.11 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.7 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js
active_record_survey_api-0.0.6 spec/test_app/vendor/assets/bower_components/angular-ui/modules/directives/scrollfix/test/scrollfixSpec.js