Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 5968515

Browse files
committed
test: rewrite tests to work whith disabled debugInfo
1 parent 9f5d328 commit 5968515

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

test/sortable.e2e.callbacks.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('uiSortable', function() {
4141
$rootScope.$apply(function() {
4242
$rootScope.opts = {
4343
update: function(e, ui) {
44-
if (ui.item.scope().item === 'Two') {
44+
if (ui.item.sortable.model === 'Two') {
4545
ui.item.sortable.cancel();
4646
}
4747
}
@@ -83,7 +83,7 @@ describe('uiSortable', function() {
8383
return item;
8484
},
8585
update: function(e, ui) {
86-
if (ui.item.scope().item === 'Two') {
86+
if (ui.item.sortable.model === 'Two') {
8787
ui.item.sortable.cancel();
8888
}
8989
}
@@ -123,7 +123,7 @@ describe('uiSortable', function() {
123123
$rootScope.$apply(function() {
124124
$rootScope.opts = {
125125
update: function(e, ui) {
126-
$rootScope.logs.push('Moved element ' + ui.item.scope().item);
126+
$rootScope.logs.push('Moved element ' + ui.item.sortable.model);
127127
}
128128
};
129129
$rootScope.items = ['One', 'Two', 'Three'];
@@ -154,7 +154,7 @@ describe('uiSortable', function() {
154154
$rootScope.$apply(function() {
155155
$rootScope.opts = {
156156
stop: function(e, ui) {
157-
$rootScope.logs.push('Moved element ' + ui.item.scope().item);
157+
$rootScope.logs.push('Moved element ' + ui.item.sortable.model);
158158
}
159159
};
160160
$rootScope.items = ['One', 'Two', 'Three'];
@@ -205,7 +205,7 @@ describe('uiSortable', function() {
205205
$rootScope.$apply(function() {
206206
$rootScope.opts = {
207207
update: function(e, ui) {
208-
if (ui.item.scope().item === 'Two') {
208+
if (ui.item.sortable.model === 'Two') {
209209
ui.item.sortable.cancel();
210210
}
211211
updateCallbackExpectations(ui.item.sortable);
@@ -282,7 +282,7 @@ describe('uiSortable', function() {
282282
uiItemSortable_Destroy = ui.item.sortable._destroy;
283283
},
284284
update: function(e, ui) {
285-
if (ui.item.scope().item === 'Two') {
285+
if (ui.item.sortable.model === 'Two') {
286286
ui.item.sortable.cancel();
287287
}
288288
}

test/sortable.e2e.multi.spec.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ describe('uiSortable', function() {
7474
inject(function($compile, $rootScope) {
7575
var elementTop, elementBottom,
7676
wrapperTop, wrapperBottom,
77+
wrapperTopScope, wrapperBottomScope,
7778
itemsTop, itemsBottom;
78-
wrapperTop = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul></div>')($rootScope);
79-
wrapperBottom = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul></div>')($rootScope);
79+
wrapperTopScope = $rootScope.$new();
80+
wrapperBottomScope = $rootScope.$new();
81+
wrapperTop = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul></div>')(wrapperTopScope);
82+
wrapperBottom = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul></div>')(wrapperBottomScope);
8083

8184
host.append(wrapperTop).append(wrapperBottom).append('<div class="clear"></div>');
8285
$rootScope.$apply(function() {
83-
wrapperTop.scope().itemsTop = itemsTop = ['Top One', 'Top Two', 'Top Three'];
84-
wrapperBottom.scope().itemsBottom = itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
86+
wrapperTopScope.itemsTop = itemsTop = ['Top One', 'Top Two', 'Top Three'];
87+
wrapperBottomScope.itemsBottom = itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
8588
$rootScope.opts = { connectWith: '.cross-sortable' };
8689
});
8790

@@ -468,9 +471,9 @@ describe('uiSortable', function() {
468471
$rootScope.opts = {
469472
connectWith: '.cross-sortable',
470473
update: function(e, ui) {
471-
if (ui.item.scope() &&
472-
(typeof ui.item.scope().item === 'string') &&
473-
ui.item.scope().item.indexOf('Two') >= 0) {
474+
if (ui.item.sortable.model &&
475+
(typeof ui.item.sortable.model === 'string') &&
476+
ui.item.sortable.model.indexOf('Two') >= 0) {
474477
ui.item.sortable.cancel();
475478
}
476479
}
@@ -527,9 +530,9 @@ describe('uiSortable', function() {
527530
$rootScope.opts = {
528531
connectWith: '.cross-sortable',
529532
update: function(e, ui) {
530-
if (ui.item.scope() &&
531-
(typeof ui.item.scope().item === 'string') &&
532-
ui.item.scope().item.indexOf('Two') >= 0) {
533+
if (ui.item.sortable.model &&
534+
(typeof ui.item.sortable.model === 'string') &&
535+
ui.item.sortable.model.indexOf('Two') >= 0) {
533536
ui.item.sortable.cancel();
534537
}
535538
updateCallbackExpectations(ui.item.sortable);
@@ -666,9 +669,9 @@ describe('uiSortable', function() {
666669
$rootScope.opts = {
667670
connectWith: '.cross-sortable',
668671
update: function(e, ui) {
669-
if (ui.item.scope() &&
670-
(typeof ui.item.scope().item === 'string') &&
671-
ui.item.scope().item.indexOf('Two') >= 0) {
672+
if (ui.item.sortable.model &&
673+
(typeof ui.item.sortable.model === 'string') &&
674+
ui.item.sortable.model.indexOf('Two') >= 0) {
672675
ui.item.sortable.cancel();
673676
}
674677
updateCallbackExpectations(ui.item.sortable);
@@ -735,21 +738,24 @@ describe('uiSortable', function() {
735738
inject(function($compile, $rootScope) {
736739
var elementTop, elementBottom,
737740
wrapperTop, wrapperBottom,
741+
wrapperTopScope, wrapperBottomScope,
738742
itemsTop, itemsBottom,
739743
updateCallbackExpectations;
740-
wrapperTop = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul></div>')($rootScope);
741-
wrapperBottom = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul></div>')($rootScope);
744+
wrapperTopScope = $rootScope.$new();
745+
wrapperBottomScope = $rootScope.$new();
746+
wrapperTop = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul></div>')(wrapperTopScope);
747+
wrapperBottom = $compile('<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul></div>')(wrapperBottomScope);
742748

743749
host.append(wrapperTop).append(wrapperBottom).append('<div class="clear"></div>');
744750
$rootScope.$apply(function() {
745-
wrapperTop.scope().itemsTop = itemsTop = ['Top One', 'Top Two', 'Top Three'];
746-
wrapperBottom.scope().itemsBottom = itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
751+
wrapperTopScope.itemsTop = itemsTop = ['Top One', 'Top Two', 'Top Three'];
752+
wrapperBottomScope.itemsBottom = itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
747753
$rootScope.opts = {
748754
connectWith: '.cross-sortable',
749755
update: function(e, ui) {
750-
if (ui.item.scope() &&
751-
(typeof ui.item.scope().item === 'string') &&
752-
ui.item.scope().item.indexOf('Two') >= 0) {
756+
if (ui.item.sortable.model &&
757+
(typeof ui.item.sortable.model === 'string') &&
758+
ui.item.sortable.model.indexOf('Two') >= 0) {
753759
ui.item.sortable.cancel();
754760
}
755761
updateCallbackExpectations(ui.item.sortable);
@@ -830,9 +836,9 @@ describe('uiSortable', function() {
830836
},
831837
update: function(e, ui) {
832838
uiItem.sortable = ui.item.sortable;
833-
if (ui.item.scope() &&
834-
(typeof ui.item.scope().item === 'string') &&
835-
ui.item.scope().item.indexOf('Two') >= 0) {
839+
if (ui.item.sortable.model &&
840+
(typeof ui.item.sortable.model === 'string') &&
841+
ui.item.sortable.model.indexOf('Two') >= 0) {
836842
ui.item.sortable.cancel();
837843
}
838844
}

0 commit comments

Comments
 (0)