mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(slidebox): refactor for performance and stability
Closes #2336. Closes #2317. Closes #2290. Closes #2228. Closes #2067. Closes #1890. Closes #1865. Closes #1850. Closes #1755. Closes #1688. Closes #1578. Closes #1501. Closes #1353. Closes #1342. Closes #782. Closes #416. Closes #2288. BREAKING CHANGE: The slideBox's API has undergone many changes. - **`<ion-slide-box>`** attributes have changed (see [documentation](http://ionicframework.com/docs/api/directive/ionSlideBox)): * `active-slide` has changed to `selected`. Change your code from this: ```html <ion-slide-box active-slide="activeSlideIndex"></ion-slide-box> ``` To this: ```html <ion-slide-box selected="activeSlideIndex"></ion-slide-box> ``` * `does-continue` has changed to `loop`. Change your code from this: ```html <ion-slide-box does-continue="shouldLoop"></ion-slide-box> ``` To this: ```html <ion-slide-box loop="shouldLoop"></ion-slide-box> ``` * `auto-play` and `slide-interval` have been merged into `auto-play`. Change your code from this: ```html <!-- autoPlay is on --> <ion-slide-box auto-play="true" slide-interval="1000"> </ion-slide-box> <!-- autoPlay is off --> <ion-slide-box auto-play="false" slide-interval="1000"> </ion-slide-box> ``` To this: ```html <!-- autoPlay is on --> <ion-slide-box auto-play="1000"></ion-slide-box> <!-- autoPlay is off --> <ion-slide-box auto-play="false"></ion-slide-box> ``` * `show-pager` and `pager-click` have been removed. Use a child `<ion-slide-pager>` element. See the [`ion-slide-pager` documentation](http://ionicframework.com/docs/api/directive/ionSlidePager). Change your code from this: ```html <!-- pager using default click action --> <ion-slide-box show-pager="true"> </ion-slide-box> <!-- pager with custom click action --> <ion-slide-box show-pager="true" pager-click="doSomething(index)"> </ion-slide-box> ``` To this: ```html <ion-slide-box> <!-- pager using default click action --> <ion-slide-pager></ion-slide-pager> </ion-slide-box> <ion-slide-box> <!-- pager with custom click action --> <ion-slide-pager ng-click="doSomething(index)"></ion-slide-pager> </ion-slide-box> ``` - **`$ionicSlideBoxDelegate`** methods have changed (see [documentation](http://ionicframework.com/docs/api/service/$ionicSlideBoxDelegate)): - `update()` has been removed. slideBox updates on its own now. - `stop()` has been removed. See `autoPlay()` below. - `start()` hass been removed. See `autoPlay()` below. - `slide(newIndex[, speed])` has been renamed to `select(newIndex[, speed]); - `currentIndex()` has been renamed to `selected()`. - `slidesCount()` has been renamed to `count()`. - New method `$ionicSlideBoxDelegate.autoPlay()`. Change your code from this: ```js // stop auto sliding $ionicSlideBoxDelegate.stop(); // later... start auto sliding $ionicSlideBoxDelegate.start(); ``` To this: ```js var autoPlaySpeed = 3000; //wait 3000 seconds between changing slide // stop auto sliding $ionicSlideBoxDelegate.autoPlay(false); // later... start auto sliding $ionicSlideBoxDelegate.autoPlay(autoPlaySpeed); ``` - `previous()` now returns the index of the previous slide and does not select. Change your code from this: ```js // select previous slide $ionicSlideBoxDelegate.previous(); ``` To this: ```js // select previous slide $ionicSlideBoxDelegate.select( $ionicSlideBoxDelegate.previous() ); ``` - `next()` now returns the index of the next slide and does not select. Change your code from this: ```js // select next slide $ionicSlideBoxDelegate.next(); ``` To this: ```js // select next slide $ionicSlideBoxDelegate.select( $ionicSlideBoxDelegate.next() ); ```
This commit is contained in:
178
test/unit/angular/controller/slideBoxController.unit.js
Normal file
178
test/unit/angular/controller/slideBoxController.unit.js
Normal file
@@ -0,0 +1,178 @@
|
||||
describe('$ionSlideBox controller', function() {
|
||||
beforeEach(module('ionic'));
|
||||
|
||||
|
||||
function mockSlide() {
|
||||
return {
|
||||
onAdded: jasmine.createSpy('onAdded'),
|
||||
onRemoved: jasmine.createSpy('onRemoved'),
|
||||
setState: jasmine.createSpy('setState'),
|
||||
transform: jasmine.createSpy('transform')
|
||||
};
|
||||
}
|
||||
function makeCtrl(locals) {
|
||||
var ctrl;
|
||||
inject(function($controller, $rootScope) {
|
||||
ctrl = $controller('$ionSlideBox', extend({
|
||||
$scope: $rootScope.$new(),
|
||||
$element: angular.element('<div class="slider"><div class="slider-slides"></div></div>')
|
||||
}, locals));
|
||||
});
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
it('#add()', inject(function($rootScope, $timeout) {
|
||||
var ctrl = makeCtrl();
|
||||
var slide1 = mockSlide();
|
||||
var slide2 = mockSlide();
|
||||
|
||||
expect(ctrl.selected()).toBe(-1);
|
||||
ctrl.add(slide1);
|
||||
expect(ctrl.selected()).toBe(0);
|
||||
expect(ctrl.count()).toBe(1);
|
||||
$timeout.flush();
|
||||
expect(slide1.setState).toHaveBeenCalledWith('selected');
|
||||
|
||||
ctrl.add(slide2);
|
||||
$rootScope.$apply();
|
||||
expect(ctrl.selected()).toBe(0);
|
||||
expect(ctrl.count()).toBe(2);
|
||||
$timeout.flush();
|
||||
expect(slide2.setState).toHaveBeenCalledWith('next');
|
||||
}));
|
||||
|
||||
it('#remove()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
var slide0, slide1, slide2;
|
||||
ctrl.add(slide0 = mockSlide());
|
||||
ctrl.add(slide1 = mockSlide());
|
||||
ctrl.add(slide2 = mockSlide());
|
||||
|
||||
ctrl.select(1);
|
||||
expect(ctrl.selected()).toBe(1);
|
||||
|
||||
ctrl.remove(slide1);
|
||||
expect(ctrl.selected()).toBe(1);
|
||||
expect(ctrl.at(1)).toBe(slide2);
|
||||
|
||||
ctrl.remove(slide2);
|
||||
expect(ctrl.selected()).toBe(0);
|
||||
});
|
||||
|
||||
it('#move()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
var slide0, slide1;
|
||||
ctrl.add(slide0 = mockSlide());
|
||||
ctrl.add(slide1 = mockSlide());
|
||||
|
||||
expect(ctrl.at(1)).toBe(slide1);
|
||||
ctrl.move(slide1, 0);
|
||||
expect(ctrl.at(0)).toBe(slide1);
|
||||
expect(ctrl.at(1)).toBe(slide0);
|
||||
});
|
||||
|
||||
it('#onDrag()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
var slide0, slide1, slide2;
|
||||
ctrl.add(slide0 = mockSlide());
|
||||
ctrl.add(slide1 = mockSlide());
|
||||
ctrl.add(slide2 = mockSlide());
|
||||
|
||||
ctrl.select(1);
|
||||
// Transforming forward should move current and next
|
||||
ctrl.onDrag(0.5);
|
||||
expect(slide0.transform).not.toHaveBeenCalled();
|
||||
expect(slide1.transform).toHaveBeenCalledWith(0.5);
|
||||
expect(slide2.transform).toHaveBeenCalledWith(0.5);
|
||||
|
||||
slide0.transform.reset();
|
||||
slide1.transform.reset();
|
||||
slide2.transform.reset();
|
||||
|
||||
// Transforming backward should move current and prev
|
||||
ctrl.onDrag(-0.5);
|
||||
expect(slide0.transform).toHaveBeenCalledWith(-0.5);
|
||||
expect(slide1.transform).toHaveBeenCalledWith(-0.5);
|
||||
expect(slide2.transform).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('#onDragEnd()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
var slide0, slide1, slide2;
|
||||
ctrl.add(slide0 = mockSlide());
|
||||
ctrl.add(slide1 = mockSlide());
|
||||
ctrl.add(slide2 = mockSlide());
|
||||
|
||||
ctrl.select(1);
|
||||
// Greater than 0.5 should change slide
|
||||
ctrl.onDragEnd(-0.75, 0);
|
||||
expect(ctrl.selected()).toBe(0);
|
||||
ctrl.onDragEnd(0.75, 0);
|
||||
expect(ctrl.selected()).toBe(1);
|
||||
// Less shouldn't
|
||||
ctrl.onDragEnd(0.25, 0);
|
||||
expect(ctrl.selected()).toBe(1);
|
||||
});
|
||||
|
||||
it('#isRelevant()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
|
||||
ctrl.loop(false);
|
||||
ctrl.select(0);
|
||||
expect(ctrl.isRelevant(4)).toBe(false);
|
||||
expect(ctrl.isRelevant(0)).toBe(true);
|
||||
expect(ctrl.isRelevant(1)).toBe(true);
|
||||
expect(ctrl.isRelevant(2)).toBe(false);
|
||||
|
||||
ctrl.loop(true);
|
||||
expect(ctrl.isRelevant(3)).toBe(false);
|
||||
expect(ctrl.isRelevant(4)).toBe(true);
|
||||
expect(ctrl.isRelevant(0)).toBe(true);
|
||||
expect(ctrl.isRelevant(1)).toBe(true);
|
||||
expect(ctrl.isRelevant(2)).toBe(false);
|
||||
});
|
||||
|
||||
it('#previous()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
|
||||
ctrl.loop(false);
|
||||
ctrl.select(0);
|
||||
expect(ctrl.previous()).toBe(-1);
|
||||
ctrl.select(1);
|
||||
expect(ctrl.previous()).toBe(0);
|
||||
|
||||
ctrl.loop(true);
|
||||
ctrl.select(0);
|
||||
expect(ctrl.previous()).toBe(2);
|
||||
ctrl.select(1);
|
||||
expect(ctrl.previous()).toBe(0);
|
||||
});
|
||||
|
||||
it('#next()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
ctrl.add(mockSlide());
|
||||
|
||||
ctrl.loop(false);
|
||||
ctrl.select(2);
|
||||
expect(ctrl.next()).toBe(-1);
|
||||
ctrl.select(1);
|
||||
expect(ctrl.next()).toBe(2);
|
||||
|
||||
ctrl.loop(true);
|
||||
ctrl.select(2);
|
||||
expect(ctrl.next()).toBe(0);
|
||||
ctrl.select(1);
|
||||
expect(ctrl.next()).toBe(2);
|
||||
});
|
||||
|
||||
});
|
||||
55
test/unit/angular/controller/slideController.unit.js
Normal file
55
test/unit/angular/controller/slideController.unit.js
Normal file
@@ -0,0 +1,55 @@
|
||||
describe('$ionSlide controller', function() {
|
||||
beforeEach(module('ionic'));
|
||||
|
||||
function makeCtrl() {
|
||||
var ctrl;
|
||||
inject(function($rootScope, $controller) {
|
||||
ctrl = $controller('$ionSlide', {
|
||||
$scope: $rootScope.$new(),
|
||||
$element: angular.element('<div>')
|
||||
});
|
||||
});
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
it('#onAdded()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
expect(ctrl.state).toBeFalsy();
|
||||
ctrl.onAdded(parent);
|
||||
expect(ctrl.state).toBe('detached');
|
||||
});
|
||||
|
||||
it('#onRemoved()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
expect(ctrl.state).toBeFalsy();
|
||||
ctrl.onRemoved();
|
||||
expect(ctrl.state).toBe('detached');
|
||||
});
|
||||
|
||||
it('#setState()', function() {
|
||||
var ctrl = makeCtrl();
|
||||
ctrl.onAdded(angular.element('<div>'));
|
||||
|
||||
expect(ctrl.element.parent().length).toBe(0);
|
||||
ctrl.setState('selected');
|
||||
expect(ctrl.element.attr('slide-state')).toBe('selected');
|
||||
expect(ctrl.element.attr('slide-previous-state')).toBe('detached');
|
||||
expect(ctrl.element.parent()[0]).toBe(ctrl.parentElement[0]);
|
||||
|
||||
ctrl.setState('previous');
|
||||
expect(ctrl.element.attr('slide-state')).toBe('previous');
|
||||
expect(ctrl.element.attr('slide-previous-state')).toBe('selected');
|
||||
expect(ctrl.element.parent()[0]).toBe(ctrl.parentElement[0]);
|
||||
|
||||
ctrl.setState('detached');
|
||||
expect(ctrl.element.attr('slide-state')).toBe('detached');
|
||||
expect(ctrl.element.attr('slide-previous-state')).toBe('previous');
|
||||
expect(ctrl.element.parent().length).toBe(0);
|
||||
|
||||
ctrl.setState('next');
|
||||
expect(ctrl.element.attr('slide-state')).toBe('next');
|
||||
expect(ctrl.element.attr('slide-previous-state')).toBe('detached');
|
||||
expect(ctrl.element.parent()[0]).toBe(ctrl.parentElement[0]);
|
||||
|
||||
});
|
||||
});
|
||||
22
test/unit/angular/directive/slide.unit.js
Normal file
22
test/unit/angular/directive/slide.unit.js
Normal file
@@ -0,0 +1,22 @@
|
||||
describe('ionSlide directive', function() {
|
||||
beforeEach(module('ionic'));
|
||||
|
||||
it('should add and remove itself from parent ctrl', inject(function($compile, $rootScope) {
|
||||
var parent = $compile('<ion-scroll><ion-slide-box>' +
|
||||
'<ion-slide>Hello</ion-slide>' +
|
||||
'</ion-slide-box></ion-scroll>')($rootScope.$new());
|
||||
|
||||
$rootScope.$apply();
|
||||
var slideBox = parent.find('ion-slide-box');
|
||||
var slide = slideBox.find('ion-slide');
|
||||
|
||||
var slideBoxCtrl = slideBox.controller('ionSlideBox');
|
||||
var slideCtrl = slide.controller('ionSlide');
|
||||
expect(slideBoxCtrl.count()).toBe(1);
|
||||
expect(slideBoxCtrl.at(0)).toBe(slideCtrl);
|
||||
|
||||
slide.scope().$broadcast('$destroy');
|
||||
expect(slideBoxCtrl.count()).toBe(0);
|
||||
}));
|
||||
|
||||
});
|
||||
@@ -1,73 +1,104 @@
|
||||
/**
|
||||
* Test the side menu directive. For more test coverage of the side menu,
|
||||
* see the core Ionic sideMenu controller tests.
|
||||
*/
|
||||
describe('Ionic Angular Slide Box', function() {
|
||||
var el, compile, rootScope, timeout;
|
||||
|
||||
describe('ionSlideBox directive', function() {
|
||||
beforeEach(module('ionic'));
|
||||
beforeEach(function() {
|
||||
spyOn(ionic, 'requestAnimationFrame').andCallFake(function(cb) { cb(); });
|
||||
});
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope, $timeout) {
|
||||
timeout = $timeout;
|
||||
rootScope = $rootScope;
|
||||
compile = $compile;
|
||||
|
||||
el = $compile('<ion-slide-box>' +
|
||||
'<ion-slide>' +
|
||||
'<div class="box blue">' +
|
||||
'<h1>BLUE {{slideBox.slideIndex}}</h1>' +
|
||||
'</div>' +
|
||||
'</ion-slide>' +
|
||||
'<ion-slide>' +
|
||||
'<div class="box yellow">' +
|
||||
'<h1>YELLOW {{slideBox.slideIndex}}</h1>' +
|
||||
'</div>' +
|
||||
'</ion-slide>' +
|
||||
'<ion-slide>' +
|
||||
'<div class="box pink"><h1>PINK {{slideBox.slideIndex}}</h1></div>' +
|
||||
'</ion-slide>' +
|
||||
'</ion-slide-box>')($rootScope);
|
||||
}));
|
||||
|
||||
it('should register with $ionicSlideBoxDelegate', inject(function($compile, $rootScope, $ionicSlideBoxDelegate) {
|
||||
var deregisterSpy = jasmine.createSpy('deregister');
|
||||
spyOn($ionicSlideBoxDelegate, '_registerInstance').andCallFake(function() {
|
||||
return deregisterSpy;
|
||||
function makeSlideBox(template) {
|
||||
var el;
|
||||
inject(function($compile, $rootScope) {
|
||||
el = $compile('<ion-scroll>' + template + '</ion-scroll>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
});
|
||||
var el = $compile('<ion-slide-box delegate-handle="superHandle">')($rootScope.$new());
|
||||
$rootScope.$apply();
|
||||
return el.find('ion-slide-box');
|
||||
}
|
||||
|
||||
expect($ionicSlideBoxDelegate._registerInstance)
|
||||
.toHaveBeenCalledWith(el.controller('ionSlideBox').__slider, 'superHandle');
|
||||
it('should bind to selected attr', inject(function($rootScope, $timeout) {
|
||||
var slideBox = makeSlideBox('<ion-slide-box selected="$root.currentIndex">' +
|
||||
'<ion-slide>A</ion-slide>' +
|
||||
'<ion-slide>B</ion-slide>' +
|
||||
'<ion-slide>C</ion-slide>' +
|
||||
'</ion-slide-box>');
|
||||
|
||||
expect(deregisterSpy).not.toHaveBeenCalled();
|
||||
el.scope().$destroy();
|
||||
expect(deregisterSpy).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('ionSlideBox with active slide', function() {
|
||||
beforeEach(module('ionic'));
|
||||
|
||||
it('Should set initial active slide', inject(function($ionicSlideBoxDelegate, $rootScope, $compile) {
|
||||
el = $compile('<ion-slide-box active-slide="2">' +
|
||||
'<ion-slide>' +
|
||||
'<div class="box blue">' +
|
||||
'<h1>BLUE {{slideBox.slideIndex}}</h1>' +
|
||||
'</div>' +
|
||||
'</ion-slide>' +
|
||||
'<ion-slide>' +
|
||||
'<div class="box yellow">' +
|
||||
'<h1>YELLOW {{slideBox.slideIndex}}</h1>' +
|
||||
'</div>' +
|
||||
'</ion-slide>' +
|
||||
'<ion-slide>' +
|
||||
'<div class="box pink"><h1>PINK {{slideBox.slideIndex}}</h1></div>' +
|
||||
'</ion-slide>' +
|
||||
'</ion-slide-box>')($rootScope.$new());
|
||||
|
||||
var scope = el.scope();
|
||||
scope.$apply();
|
||||
expect($ionicSlideBoxDelegate.currentIndex()).toBe(2);
|
||||
var slideBoxCtrl = slideBox.controller('ionSlideBox');
|
||||
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
$timeout.flush();
|
||||
expect($rootScope.currentIndex).toBe(0);
|
||||
|
||||
$rootScope.$apply('currentIndex = 2');
|
||||
expect(slideBoxCtrl.selected()).toBe(2);
|
||||
|
||||
slideBoxCtrl.select(1);
|
||||
$timeout.flush();
|
||||
expect($rootScope.currentIndex).toBe(1);
|
||||
|
||||
// No out of bounds
|
||||
expect(slideBoxCtrl.selected()).toBe(1);
|
||||
$rootScope.$apply('currentIndex = -1');
|
||||
expect(slideBoxCtrl.selected()).toBe(1);
|
||||
$rootScope.$apply('currentIndex = 3');
|
||||
expect(slideBoxCtrl.selected()).toBe(1);
|
||||
}));
|
||||
|
||||
it('should loop depending on attr.loop', inject(function($rootScope) {
|
||||
var slideBox = makeSlideBox('<ion-slide-box loop="shouldLoop">' +
|
||||
'<ion-slide>A</ion-slide>' +
|
||||
'<ion-slide>B</ion-slide>' +
|
||||
'<ion-slide>C</ion-slide>' +
|
||||
'</ion-slide-box>');
|
||||
|
||||
$rootScope.$apply('shouldLoop = true');
|
||||
|
||||
var slideBoxCtrl = slideBox.controller('ionSlideBox');
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
slideBoxCtrl.select(slideBoxCtrl.previous());
|
||||
expect(slideBoxCtrl.selected()).toBe(2);
|
||||
slideBoxCtrl.select(slideBoxCtrl.next());
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
|
||||
// Disable looping
|
||||
$rootScope.$apply('shouldLoop = false');
|
||||
|
||||
// No loop at previous boundary
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
slideBoxCtrl.select(slideBoxCtrl.previous());
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
|
||||
// No loop at next boundary
|
||||
slideBoxCtrl.select(2);
|
||||
expect(slideBoxCtrl.selected()).toBe(2);
|
||||
slideBoxCtrl.select(slideBoxCtrl.next());
|
||||
expect(slideBoxCtrl.selected()).toBe(2);
|
||||
}));
|
||||
|
||||
it('should autoplay depending on attr.autoPlay', inject(function($rootScope, $interval) {
|
||||
var slideBox = makeSlideBox('<ion-slide-box loop="shouldLoop" auto-play="playInterval">' +
|
||||
'<ion-slide>A</ion-slide>' +
|
||||
'<ion-slide>B</ion-slide>' +
|
||||
'<ion-slide>C</ion-slide>' +
|
||||
'</ion-slide-box>');
|
||||
|
||||
$rootScope.$apply('shouldLoop = false; playInterval = 1000;');
|
||||
|
||||
var slideBoxCtrl = slideBox.controller('ionSlideBox');
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
$interval.flush(1000);
|
||||
expect(slideBoxCtrl.selected()).toBe(1);
|
||||
$interval.flush(1000);
|
||||
expect(slideBoxCtrl.selected()).toBe(2);
|
||||
// Should not go beyond limit with loop disabled
|
||||
$interval.flush(1000);
|
||||
expect(slideBoxCtrl.selected()).toBe(2);
|
||||
|
||||
// Should loop
|
||||
$rootScope.$apply('shouldLoop = true');
|
||||
$interval.flush(1000);
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
|
||||
// Should deactivate and stop looping
|
||||
$rootScope.$apply('playInterval = -1');
|
||||
$interval.flush();
|
||||
expect(slideBoxCtrl.selected()).toBe(0);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -105,10 +105,10 @@ describe('$collectionDataSource service', function() {
|
||||
var item = {
|
||||
scope: {},
|
||||
};
|
||||
spyOn(window, 'reconnectScope');
|
||||
spyOn(ionic.Utils, 'reconnectScope');
|
||||
source.backupItemsArray = [item];
|
||||
expect(source.getItem('123')).toBe(item);
|
||||
expect(reconnectScope).toHaveBeenCalledWith(item.scope);
|
||||
expect(ionic.Utils.reconnectScope).toHaveBeenCalledWith(item.scope);
|
||||
});
|
||||
|
||||
it('should last resort create an item', function() {
|
||||
@@ -172,11 +172,11 @@ describe('$collectionDataSource service', function() {
|
||||
};
|
||||
source.backupItemsArray = [];
|
||||
source.attachedItems[1] = item;
|
||||
spyOn(window, 'disconnectScope');
|
||||
spyOn(ionic.Utils, 'disconnectScope');
|
||||
source.detachItem(item);
|
||||
expect(source.attachedItems).toEqual({});
|
||||
expect(source.backupItemsArray).toEqual([item]);
|
||||
expect(disconnectScope).toHaveBeenCalledWith(item.scope);
|
||||
expect(ionic.Utils.disconnectScope).toHaveBeenCalledWith(item.scope);
|
||||
});
|
||||
it('should remove element from parent and disconnectScope if backupItemsArray is full', function() {
|
||||
var source = setup();
|
||||
|
||||
Reference in New Issue
Block a user