mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
style(): move listController.unit.js to correct dir
This commit is contained in:
67
test/unit/angular/controller/listController.unit.js
Normal file
67
test/unit/angular/controller/listController.unit.js
Normal file
@@ -0,0 +1,67 @@
|
||||
describe('$ionicList controller', function() {
|
||||
beforeEach(module('ionic'));
|
||||
function setup(attrs) {
|
||||
var ctrl;
|
||||
inject(function($controller, $rootScope) {
|
||||
var scope = $rootScope.$new();
|
||||
ctrl = $controller('$ionicList', {
|
||||
$scope: scope,
|
||||
$attrs: attrs || {},
|
||||
});
|
||||
ctrl.$scope = scope;
|
||||
});
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
it('should register with handle', inject(function($ionicListDelegate) {
|
||||
spyOn($ionicListDelegate, '_registerInstance');
|
||||
var ctrl = setup({delegateHandle: 'foobar'});
|
||||
expect($ionicListDelegate._registerInstance)
|
||||
.toHaveBeenCalledWith(ctrl, 'foobar');
|
||||
}));
|
||||
|
||||
it('should register with given handle and deregister on destroy', inject(function($ionicListDelegate) {
|
||||
var deregisterSpy = jasmine.createSpy('deregister');
|
||||
spyOn($ionicListDelegate, '_registerInstance').andCallFake(function() {
|
||||
return deregisterSpy;
|
||||
});
|
||||
var ctrl = setup({
|
||||
delegateHandle: 'something'
|
||||
});
|
||||
expect($ionicListDelegate._registerInstance)
|
||||
.toHaveBeenCalledWith(ctrl, 'something');
|
||||
|
||||
expect(deregisterSpy).not.toHaveBeenCalled();
|
||||
ctrl.$scope.$destroy();
|
||||
expect(deregisterSpy).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('.showReorder sets/gets', function() {
|
||||
var ctrl = setup();
|
||||
expect(ctrl.showReorder()).toBe(false);
|
||||
ctrl.showReorder(true);
|
||||
expect(ctrl.showReorder()).toBe(true);
|
||||
});
|
||||
|
||||
it('.showDelete sets/gets', function() {
|
||||
var ctrl = setup();
|
||||
expect(ctrl.showDelete()).toBe(false);
|
||||
ctrl.showDelete(true);
|
||||
expect(ctrl.showDelete()).toBe(true);
|
||||
});
|
||||
|
||||
it('.canSwipeItems sets/gets', function() {
|
||||
var ctrl = setup();
|
||||
expect(ctrl.canSwipeItems()).toBe(true);
|
||||
ctrl.canSwipeItems(false);
|
||||
expect(ctrl.canSwipeItems()).toBe(false);
|
||||
});
|
||||
|
||||
it('.closeOptionButtons closes calls clearDragEffects', function() {
|
||||
var ctrl = setup();
|
||||
ctrl.listView = { clearDragEffects: jasmine.createSpy('clearDragEffects') };
|
||||
ctrl.closeOptionButtons();
|
||||
expect(ctrl.listView.clearDragEffects).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user