Skip to content

Commit c635ff0

Browse files
committed
chore(tests): Refactoring arrow visibility tests
1 parent 5bb9d62 commit c635ff0

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed

src/timepicker/test/timepicker.spec.js

+9-45
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ describe('timepicker directive', function () {
376376
expect(getModelState()).toEqual([14, 40]);
377377
});
378378

379+
it('displays arrows controls by default correctly', function () {
380+
$rootScope.$digest();
381+
expect(element.find('tr').length).toBe(3);
382+
});
383+
379384
describe('attributes', function () {
380385
beforeEach(function() {
381386
$rootScope.hstep = 2;
@@ -874,73 +879,32 @@ describe('timepicker directive', function () {
874879
});
875880
});
876881

877-
describe('setting timepickerConfig arrow controls default visibility', function () {
878-
879-
beforeEach(inject(function(_$compile_, _$rootScope_, timepickerConfig) {
880-
element = $compile('<timepicker ng-model="time" ng-required="true"></timepicker>')($rootScope);
881-
$rootScope.$digest();
882-
}));
883-
884-
function countElementsTr(isUp) {
885-
return element.find('tr').length;
886-
}
887-
888-
it('displays arrows controls by default correctly', function () {
889-
$rootScope.$digest();
890-
891-
var upElementsCount = countElementsTr(true);
892-
var downElementsCount = countElementsTr(false);
893-
894-
expect(upElementsCount).toBe(3);
895-
expect(downElementsCount).toBe(3);
896-
});
897-
898-
});
899-
900882
describe('setting timepickerConfig arrow controls check initial show', function () {
901883

902-
beforeEach(inject(function(_$compile_, _$rootScope_, timepickerConfig) {
884+
beforeEach(inject(function(_$compile_, _$rootScope_) {
903885
$rootScope.showArrowsControls = true;
904886
element = $compile('<timepicker ng-model="time" ng-required="true" show-arrows-controls="showArrowsControls"></timepicker>')($rootScope);
905887
$rootScope.$digest();
906888
}));
907889

908-
function countElementsTr(isUp) {
909-
return element.find('tr').length;
910-
}
911-
912890
it('displays arrows controls correctly', function () {
913891
$rootScope.$digest();
914-
915-
var upElementsCount = countElementsTr(true);
916-
var downElementsCount = countElementsTr(false);
917-
918-
expect(upElementsCount).toBe(3);
919-
expect(downElementsCount).toBe(3);
892+
expect(element.find('tr').length).toBe(3);
920893
});
921894

922895
});
923896

924897
describe('setting timepickerConfig arrow controls check initial hide', function () {
925898

926-
beforeEach(inject(function(_$compile_, _$rootScope_, timepickerConfig) {
899+
beforeEach(inject(function(_$compile_, _$rootScope_) {
927900
$rootScope.showArrowsControls = false;
928901
element = $compile('<timepicker ng-model="time" ng-required="true" show-arrows-controls="showArrowsControls"></timepicker>')($rootScope);
929902
$rootScope.$digest();
930903
}));
931904

932-
function countElementsTr(isUp) {
933-
return element.find('tr').length;
934-
}
935-
936905
it('hides arrows controls correctly', function () {
937906
$rootScope.$digest();
938-
939-
var upElementsCount = countElementsTr(true);
940-
var downElementsCount = countElementsTr(false);
941-
942-
expect(upElementsCount).toBe(1);
943-
expect(downElementsCount).toBe(1);
907+
expect(element.find('tr').length).toBe(1);
944908
});
945909

946910
});

0 commit comments

Comments
 (0)