Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
updated slider unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBurleson committed Sep 27, 2014
1 parent 1d99105 commit 0ddca06
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/components/slider/slider.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

describe('material-slider', function() {

function simulateEventAt( centerX, eventType ) {
return {
eventType: eventType,
center: { x: centerX },
preventDefault: angular.noop,
srcEvent : {
stopPropagation : angular.noop
}
};
}

beforeEach(module('material.components.slider','material.decorators'));

it('should set model on press', inject(function($compile, $rootScope, $timeout) {
Expand All @@ -14,25 +25,16 @@ describe('material-slider', function() {
right: 0
});

sliderCtrl._onInput({
eventType: Hammer.INPUT_START,
center: { x: 30 }
});
sliderCtrl._onInput( simulateEventAt( 30, Hammer.INPUT_START ));
$timeout.flush();
expect($rootScope.value).toBe(30);

//When going past max, it should clamp to max
sliderCtrl._onPan({
center: { x: 500 },
preventDefault: angular.noop
});
sliderCtrl._onPan( simulateEventAt( 500 ));
$timeout.flush();
expect($rootScope.value).toBe(100);

sliderCtrl._onPan({
center: { x: 50 },
preventDefault: angular.noop
});
sliderCtrl._onPan( simulateEventAt( 50 ));
$timeout.flush();
expect($rootScope.value).toBe(50);
}));
Expand Down

0 comments on commit 0ddca06

Please sign in to comment.