-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for right/left/up/down/buttom/top clicked
- Loading branch information
1 parent
8f4ae7f
commit b5ffae5
Showing
1 changed file
with
152 additions
and
0 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
spec/javascripts/components/generic_object_definition/assign-buttons_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
describe('assign-button', function() { | ||
var $componentController, vm, miqService, API, $scope; | ||
beforeEach(module('ManageIQ')); | ||
beforeEach(inject(function (_$componentController_, _miqService_, $rootScope) { | ||
$componentController = _$componentController_; | ||
miqService = _miqService_; | ||
$scope = $rootScope.$new(); | ||
|
||
//buttons | ||
b1 = {name: 'button1', id: 1}; | ||
b2 = {name: 'button2', id: 2}; | ||
b3 = {name: 'button3', id: 3}; | ||
b4 = {name: 'button4', id: 4}; | ||
b5 = {name: 'button5', id: 5}; | ||
b6 = {name: 'button6', id: 6}; | ||
b7 = {name: 'button7', id: 7}; | ||
b8 = {name: 'button8', id: 8}; | ||
b9 = {name: 'button9', id: 9}; | ||
b10 = {name: 'button10', id: 10}; | ||
b11 = {name: 'button11', id: 11}; | ||
b12 = {name: 'button12', id: 12}; | ||
|
||
var bindings = { | ||
assignedButtons: [b1, b2, b3, b4, b5, b6], | ||
unassignedButtons: [b7, b8, b9, b10, b11, b12], | ||
updateButtons: function() {}}; | ||
vm = $componentController("assignButtons", null, bindings); | ||
vm.$onInit(); | ||
})); | ||
|
||
describe('#leftButtonClicked', function() { | ||
it('one button from assignedButtons is moved to the end of unassignedButtons', function() { | ||
vm.model.selectedAssignedButtons = [1]; | ||
vm.leftButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual([b2, b3, b4, b5, b6]); | ||
expect(vm.model.unassignedButtons[vm.model.unassignedButtons.length - 1]).toEqual(b1); | ||
}); | ||
|
||
it('multiple buttons from assignedButtons are moved to the end of unassignedButtons', function() { | ||
vm.model.selectedAssignedButtons = [2,4,6]; | ||
var expectedResult = vm.model.unassignedButtons.concat([b2, b4, b6]); | ||
vm.leftButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual([ b1, b3, b5]); | ||
expect(vm.model.unassignedButtons).toEqual(expectedResult); | ||
}); | ||
}); | ||
|
||
describe('#rightButtonClicked', function() { | ||
it('one button from unassignedButtons is moved to the end of assignedButtons', function() { | ||
vm.model.selectedUnassignedButtons = [7]; | ||
vm.rightButtonClicked(); | ||
expect(vm.model.unassignedButtons).toEqual([b8, b9, b10, b11, b12]); | ||
expect(vm.model.assignedButtons[vm.model.assignedButtons.length - 1]).toEqual(b7); | ||
}); | ||
|
||
it('multiple buttons from unassignedButtons are moved to the end of assignedButtons', function() { | ||
vm.model.selectedUnassignedButtons = [8,10,12]; | ||
var expectedResult = vm.model.assignedButtons.concat([b8, b10, b12]); | ||
vm.rightButtonClicked(); | ||
expect(vm.model.unassignedButtons).toEqual([b7, b9, b11]); | ||
expect(vm.model.assignedButtons).toEqual(expectedResult); | ||
}); | ||
}); | ||
|
||
describe('#upButtonClicked', function() { | ||
it('one button is moved one place up', function() { | ||
vm.model.selectedAssignedButtons = [2]; | ||
vm.upButtonClicked(); | ||
expect(vm.model.assignedButtons[0]).toEqual(b2); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [1,2,3]; | ||
var original = [].concat(vm.model.assignedButtons); | ||
vm.upButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [1,3,5]; | ||
var original = [b1, b3, b2, b5, b4, b6]; | ||
vm.upButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
}); | ||
|
||
describe('#downButtonClicked', function() { | ||
it('one button is moved one place down', function() { | ||
vm.model.selectedAssignedButtons = [5]; | ||
vm.downButtonClicked(); | ||
expect(vm.model.assignedButtons[5]).toEqual(b5); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [4,5,6]; | ||
var original = [].concat(vm.model.assignedButtons); | ||
vm.downButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [1,3,5]; | ||
var original = [b2, b1, b4, b3, b6, b5]; | ||
vm.downButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
}); | ||
|
||
describe('#bottomButtonClicked', function() { | ||
it('one button is moved one place down', function() { | ||
vm.model.selectedAssignedButtons = [1]; | ||
vm.bottomButtonClicked(); | ||
expect(vm.model.assignedButtons[5]).toEqual(b1); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [4,5,6]; | ||
var original = [].concat(vm.model.assignedButtons); | ||
vm.bottomButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [2,4,6]; | ||
var original = [b1, b3, b5, b2, b4, b6]; | ||
vm.bottomButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
}); | ||
|
||
describe('#topButtonClicked', function() { | ||
it('one button is moved to the beginning', function() { | ||
vm.model.selectedAssignedButtons = [5]; | ||
vm.topButtonClicked(); | ||
expect(vm.model.assignedButtons[0]).toEqual(b5); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [1,2,3]; | ||
var original = [].concat(vm.model.assignedButtons); | ||
vm.topButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
|
||
it('buttons preserve their relative order', function() { | ||
vm.model.selectedAssignedButtons = [1,3,5]; | ||
var original = [b1, b3, b5, b2, b4, b6]; | ||
vm.topButtonClicked(); | ||
expect(vm.model.assignedButtons).toEqual(original); | ||
}); | ||
}); | ||
}); |