mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
inventory sorting
Add inventory sorting buttons based on name, attribute, and set (armoire): - Each gear[klass] has its own sorting buttons and sorting state including costume classes - The attributes sort descending when selected, then by sum of all attributes - There is no default sort - The armoire also sorts by set which sorts by item[set] descending, it does not sort within a set (ex "1 of 3" vs "2 of 3") - Name sorts by .text() ascending
This commit is contained in:
committed by
Blade Barringer
parent
a9e0a4dfaf
commit
a6fb945120
32
test/spec/controllers/sortableInventoryCtrlSpec.js
Normal file
32
test/spec/controllers/sortableInventoryCtrlSpec.js
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
describe('Sortable Inventory Controller', function() {
|
||||
var scope;
|
||||
|
||||
beforeEach(inject(function($rootScope, $controller) {
|
||||
scope = $rootScope.$new();
|
||||
$controller('SortableInventoryController', {$scope: scope});
|
||||
}));
|
||||
|
||||
it('has no default sort order', function(){
|
||||
expect(scope.order).to.not.exist;
|
||||
});
|
||||
|
||||
it('sets sort criteria for all standard attributes', function(){
|
||||
var oldOrder = scope.order;
|
||||
|
||||
var attrs = ['con', 'int', 'per', 'str', 'name', 'set'];
|
||||
|
||||
attrs.forEach(function (attribute) {
|
||||
scope.setOrder(attribute);
|
||||
expect(scope.order).to.exist;
|
||||
expect(scope.order).to.not.eql(oldOrder);
|
||||
oldOrder = scope.order;
|
||||
});
|
||||
});
|
||||
|
||||
it('does nothing when missing sort criteria', function(){
|
||||
scope.setOrder('foooo');
|
||||
expect(scope.order).to.not.exist;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user