@@ -83,7 +83,7 @@ describe('[range selector suite]', function() {
8383
8484 } ) ;
8585
86- describe ( 'getUpdateObject' , function ( ) {
86+ describe ( 'getUpdateObject: ' , function ( ) {
8787 var axisLayout = {
8888 range : [
8989 ( new Date ( 1948 , 0 , 1 ) ) . getTime ( ) ,
@@ -132,7 +132,19 @@ describe('[range selector suite]', function() {
132132 assertRanges ( update , new Date ( 2015 , 4 , 30 ) , new Date ( 2015 , 10 , 30 ) ) ;
133133 } ) ;
134134
135- it ( 'should return update object (year-to-date case)' , function ( ) {
135+ it ( 'should return update object (5 months to-date case)' , function ( ) {
136+ var buttonLayout = {
137+ step : 'month' ,
138+ stepmode : 'to date' ,
139+ count : 5
140+ } ;
141+
142+ var update = getUpdateObject ( axisLayout , buttonLayout ) ;
143+
144+ assertRanges ( update , new Date ( 2015 , 6 , 1 ) , new Date ( 2015 , 10 , 30 ) ) ;
145+ } ) ;
146+
147+ it ( 'should return update object (1 year to-date case)' , function ( ) {
136148 var buttonLayout = {
137149 step : 'year' ,
138150 stepmode : 'to date' ,
@@ -144,6 +156,18 @@ describe('[range selector suite]', function() {
144156 assertRanges ( update , new Date ( 2015 , 0 , 1 ) , new Date ( 2015 , 10 , 30 ) ) ;
145157 } ) ;
146158
159+ it ( 'should return update object (10 year to-date case)' , function ( ) {
160+ var buttonLayout = {
161+ step : 'year' ,
162+ stepmode : 'to date' ,
163+ count : 10
164+ } ;
165+
166+ var update = getUpdateObject ( axisLayout , buttonLayout ) ;
167+
168+ assertRanges ( update , new Date ( 2006 , 0 , 1 ) , new Date ( 2015 , 10 , 30 ) ) ;
169+ } ) ;
170+
147171 it ( 'should return update object (1 year backward case)' , function ( ) {
148172 var buttonLayout = {
149173 step : 'year' ,
@@ -216,6 +240,50 @@ describe('[range selector suite]', function() {
216240
217241 assertRanges ( update , new Date ( 2015 , 10 , 29 , 23 , 59 , 50 ) , new Date ( 2015 , 10 , 30 ) ) ;
218242 } ) ;
243+
244+ it ( 'should return update object (12 hour to-date case)' , function ( ) {
245+ var buttonLayout = {
246+ step : 'hour' ,
247+ stepmode : 'to date' ,
248+ count : 12
249+ } ;
250+
251+ axisLayout . range [ 1 ] = new Date ( 2015 , 10 , 30 , 12 ) . getTime ( ) ;
252+
253+ var update = getUpdateObject ( axisLayout , buttonLayout ) ;
254+
255+ assertRanges ( update , new Date ( 2015 , 10 , 30 , 1 ) , new Date ( 2015 , 10 , 30 , 12 ) ) ;
256+ } ) ;
257+
258+ it ( 'should return update object (15 minute backward case)' , function ( ) {
259+ var buttonLayout = {
260+ step : 'minute' ,
261+ stepmode : 'to date' ,
262+ count : 20
263+ } ;
264+
265+ axisLayout . range [ 1 ] = new Date ( 2015 , 10 , 30 , 12 , 20 ) . getTime ( ) ;
266+
267+ var update = getUpdateObject ( axisLayout , buttonLayout ) ;
268+
269+ assertRanges ( update , new Date ( 2015 , 10 , 30 , 12 , 1 ) , new Date ( 2015 , 10 , 30 , 12 , 20 ) ) ;
270+ } ) ;
271+
272+ it ( 'should return update object (2 second to-date case)' , function ( ) {
273+
274+ var buttonLayout = {
275+ step : 'second' ,
276+ stepmode : 'to date' ,
277+ count : 2
278+ } ;
279+
280+ axisLayout . range [ 1 ] = new Date ( 2015 , 10 , 30 , 12 , 20 , 2 ) . getTime ( ) ;
281+
282+ var update = getUpdateObject ( axisLayout , buttonLayout ) ;
283+
284+ assertRanges ( update , new Date ( 2015 , 10 , 30 , 12 , 20 , 1 ) , new Date ( 2015 , 10 , 30 , 12 , 20 , 2 ) ) ;
285+ } ) ;
286+
219287 } ) ;
220288
221289
0 commit comments