1
1
'use strict' ;
2
2
3
3
describe ( 'uiSortable' , function ( ) {
4
-
5
- beforeEach ( module ( function ( $compileProvider ) {
6
- if ( typeof $compileProvider . debugInfoEnabled === 'function' ) {
7
- $compileProvider . debugInfoEnabled ( false ) ;
8
- }
9
- } ) ) ;
4
+ beforeEach (
5
+ module ( function ( $compileProvider ) {
6
+ if ( typeof $compileProvider . debugInfoEnabled === 'function' ) {
7
+ $compileProvider . debugInfoEnabled ( false ) ;
8
+ }
9
+ } )
10
+ ) ;
10
11
11
12
// Ensure the sortable angular module is loaded
12
13
beforeEach ( module ( 'ui.sortable' ) ) ;
13
14
beforeEach ( module ( 'ui.sortable.testHelper' ) ) ;
14
15
15
- var EXTRA_DY_PERCENTAGE , listContent , hasUndefinedProperties , beforeLiElement , afterLiElement ;
16
-
17
- beforeEach ( inject ( function ( sortableTestHelper ) {
18
- EXTRA_DY_PERCENTAGE = sortableTestHelper . EXTRA_DY_PERCENTAGE ;
19
- listContent = sortableTestHelper . listContent ;
20
- hasUndefinedProperties = sortableTestHelper . hasUndefinedProperties ;
21
- beforeLiElement = sortableTestHelper . extraElements && sortableTestHelper . extraElements . beforeLiElement ;
22
- afterLiElement = sortableTestHelper . extraElements && sortableTestHelper . extraElements . afterLiElement ;
23
- } ) ) ;
16
+ var EXTRA_DY_PERCENTAGE ,
17
+ listContent ,
18
+ hasUndefinedProperties ,
19
+ beforeLiElement ,
20
+ afterLiElement ;
21
+
22
+ beforeEach (
23
+ inject ( function ( sortableTestHelper ) {
24
+ EXTRA_DY_PERCENTAGE = sortableTestHelper . EXTRA_DY_PERCENTAGE ;
25
+ listContent = sortableTestHelper . listContent ;
26
+ hasUndefinedProperties = sortableTestHelper . hasUndefinedProperties ;
27
+ beforeLiElement =
28
+ sortableTestHelper . extraElements &&
29
+ sortableTestHelper . extraElements . beforeLiElement ;
30
+ afterLiElement =
31
+ sortableTestHelper . extraElements &&
32
+ sortableTestHelper . extraElements . afterLiElement ;
33
+ } )
34
+ ) ;
24
35
25
36
tests . description = 'Attribute Callbacks related' ;
26
- function tests ( useExtraElements ) {
27
-
37
+ function tests ( useExtraElements ) {
28
38
var host ;
29
39
30
- beforeEach ( inject ( function ( ) {
31
- host = $ ( '<div id="test-host"></div>' ) ;
32
- $ ( 'body' ) . append ( host ) ;
40
+ beforeEach (
41
+ inject ( function ( ) {
42
+ host = $ ( '<div id="test-host"></div>' ) ;
43
+ $ ( 'body' ) . append ( host ) ;
33
44
34
- if ( ! useExtraElements ) {
35
- beforeLiElement = afterLiElement = '' ;
36
- }
37
- } ) ) ;
45
+ if ( ! useExtraElements ) {
46
+ beforeLiElement = afterLiElement = '' ;
47
+ }
48
+ } )
49
+ ) ;
38
50
39
51
afterEach ( function ( ) {
40
52
host . remove ( ) ;
@@ -44,12 +56,15 @@ describe('uiSortable', function() {
44
56
it ( 'should cancel sorting of node "Two"' , function ( ) {
45
57
inject ( function ( $compile , $rootScope ) {
46
58
var element ;
47
- element = $compile ( '' . concat (
48
- '<ul ui-sortable ui-sortable-update="update" ng-model="items">' ,
49
- beforeLiElement ,
50
- '<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>' ,
51
- afterLiElement ,
52
- '</ul>' ) ) ( $rootScope ) ;
59
+ element = $compile (
60
+ '' . concat (
61
+ '<ul ui-sortable ui-sortable-update="update" ng-model="items">' ,
62
+ beforeLiElement ,
63
+ '<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>' ,
64
+ afterLiElement ,
65
+ '</ul>'
66
+ )
67
+ ) ( $rootScope ) ;
53
68
$rootScope . $apply ( function ( ) {
54
69
$rootScope . update = function ( e , ui ) {
55
70
if ( ui . item . sortable . model === 'Two' ) {
@@ -97,7 +112,8 @@ describe('uiSortable', function() {
97
112
98
113
it ( 'should call all callbacks with the proper context' , function ( ) {
99
114
inject ( function ( $compile , $rootScope ) {
100
- var element , callbackContexts = { } ;
115
+ var element ,
116
+ callbackContexts = { } ;
101
117
$rootScope . $apply ( function ( ) {
102
118
$rootScope . create = function ( ) {
103
119
callbackContexts . create = this ;
@@ -134,27 +150,28 @@ describe('uiSortable', function() {
134
150
spyOn ( $rootScope , 'deactivate' ) . and . callThrough ( ) ;
135
151
spyOn ( $rootScope , 'stop' ) . and . callThrough ( ) ;
136
152
$rootScope . items = [ 'One' , 'Two' , 'Three' ] ;
137
- element = $compile ( '' . concat (
138
- '<ul ui-sortable ' +
139
- 'ui-sortable-create="create" ' +
140
- // 'ui-sortable-helper="helper" ' +
141
- 'ui-sortable-start="start" ' +
142
- 'ui-sortable-activate="activate" ' +
143
- 'ui-sortable-update="update" ' +
144
- 'ui-sortable-before-stop="beforeStop" ' +
145
- 'ui-sortable-deactivate="deactivate" ' +
146
- 'ui-sortable-stop="stop" ' +
147
- 'ng-model="items">' ,
148
- beforeLiElement ,
149
- '<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>' ,
150
- afterLiElement +
151
- '</ul>' ) ) ( $rootScope ) ;
153
+ element = $compile (
154
+ '' . concat (
155
+ '<ul ui-sortable ' +
156
+ 'ui-sortable-create="create" ' +
157
+ // 'ui-sortable-helper="helper" ' +
158
+ 'ui-sortable-start="start" ' +
159
+ 'ui-sortable-activate="activate" ' +
160
+ 'ui-sortable-update="update" ' +
161
+ 'ui-sortable-before-stop="beforeStop" ' +
162
+ 'ui-sortable-deactivate="deactivate" ' +
163
+ 'ui-sortable-stop="stop" ' +
164
+ 'ng-model="items">' ,
165
+ beforeLiElement ,
166
+ '<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>' ,
167
+ afterLiElement + '</ul>'
168
+ )
169
+ ) ( $rootScope ) ;
152
170
} ) ;
153
171
154
172
host . append ( element ) ;
155
173
156
- $rootScope . $apply ( function ( ) {
157
- } ) ;
174
+ $rootScope . $apply ( function ( ) { } ) ;
158
175
var li = element . find ( '[ng-repeat]:eq(0)' ) ;
159
176
var dy = ( 2 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
160
177
li . simulate ( 'drag' , { dy : dy } ) ;
@@ -184,16 +201,15 @@ describe('uiSortable', function() {
184
201
} ) ;
185
202
}
186
203
187
- [ 0 , 1 ] . forEach ( function ( useExtraElements ) {
204
+ [ 0 , 1 ] . forEach ( function ( useExtraElements ) {
188
205
var testDescription = tests . description ;
189
206
190
207
if ( useExtraElements ) {
191
208
testDescription += ' with extra elements' ;
192
209
}
193
210
194
- describe ( testDescription , function ( ) {
211
+ describe ( testDescription , function ( ) {
195
212
tests ( useExtraElements ) ;
196
213
} ) ;
197
214
} ) ;
198
-
199
- } ) ;
215
+ } ) ;
0 commit comments