File tree Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -18,5 +18,14 @@ export default {
18
18
if ( $element . length === 0 ) {
19
19
throw new Error ( `Element "${ elementOrSelector } " not found for "${ property } "` ) ;
20
20
}
21
+ } ,
22
+ warn ( fn , ...args ) {
23
+ try {
24
+ fn ( ...args )
25
+ } catch ( e ) {
26
+ if ( console && console . warn ) {
27
+ console . warn ( e . message )
28
+ }
29
+ }
21
30
}
22
31
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export default class Pagination {
33
33
return ;
34
34
}
35
35
36
- Assert . anyElement ( this . options . element , 'pagination.element' ) ;
36
+ Assert . warn ( Assert . anyElement , this . options . element , 'pagination.element' ) ;
37
37
38
38
ias . on ( Events . BINDED , this . hide . bind ( this ) ) ;
39
39
ias . on ( Events . UNBINDED , this . restore . bind ( this ) ) ;
Original file line number Diff line number Diff line change @@ -124,28 +124,20 @@ describe('Pagination', () => {
124
124
} ) ;
125
125
} ) ;
126
126
127
- it ( 'should throw when element not found' , ( ) => {
127
+ it ( 'should warn when element not found' , ( ) => {
128
128
cy . InfiniteAjaxScroll ( ) . then ( ( InfiniteAjaxScroll ) => {
129
- const subject = {
130
- ias : ( ) => {
131
- new InfiniteAjaxScroll ( '.blocks' , {
132
- item : '.blocks__block' ,
133
- next : '.pager__next' ,
134
- pagination : '.pager_does_not_exist' ,
135
- bind : false
136
- } ) ;
137
- }
138
- } ;
139
-
140
- const spy = cy . spy ( subject , 'ias' ) ;
141
-
142
- try {
143
- subject . ias ( ) ;
144
- } catch ( e ) {
145
- // noop
146
- }
129
+ cy . window ( ) . then ( ( win ) => {
130
+ const spy = cy . spy ( win . console , 'warn' ) ;
131
+
132
+ let ias = new InfiniteAjaxScroll ( '.blocks' , {
133
+ item : '.blocks__block' ,
134
+ next : '.pager__next' ,
135
+ pagination : '.pager_does_not_exist' ,
136
+ bind : false
137
+ } ) ;
147
138
148
- expect ( spy ) . to . have . thrown ( 'Error' ) ;
139
+ expect ( spy ) . to . have . been . called ;
140
+ } ) ;
149
141
} ) ;
150
142
} ) ;
151
143
You can’t perform that action at this time.
0 commit comments