@@ -196,6 +196,36 @@ describe('Date.add', () => {
196196 } ) ;
197197} ) ;
198198
199+ describe ( 'Date.successor' , ( ) => {
200+ it ( 'should use the specified precision' , ( ) => {
201+ const date = Date . parse ( '2000-06-15' ) ;
202+ date . successor ( Date . Unit . YEAR ) . should . eql ( Date . parse ( '2001-06-15' ) ) ;
203+ date . successor ( Date . Unit . MONTH ) . should . eql ( Date . parse ( '2000-07-15' ) ) ;
204+ date . successor ( Date . Unit . DAY ) . should . eql ( Date . parse ( '2000-06-16' ) ) ;
205+ } ) ;
206+
207+ it ( "should use the date's finest precision when precision is not specified" , ( ) => {
208+ Date . parse ( '2000-06-15' ) . successor ( ) . should . eql ( Date . parse ( '2000-06-16' ) ) ;
209+ Date . parse ( '2000-06' ) . successor ( ) . should . eql ( Date . parse ( '2000-07' ) ) ;
210+ Date . parse ( '2000' ) . successor ( ) . should . eql ( Date . parse ( '2001' ) ) ;
211+ } ) ;
212+ } ) ;
213+
214+ describe ( 'Date.predecessor' , ( ) => {
215+ it ( 'should use the specified precision' , ( ) => {
216+ const date = Date . parse ( '2000-06-15' ) ;
217+ date . predecessor ( Date . Unit . YEAR ) . should . eql ( Date . parse ( '1999-06-15' ) ) ;
218+ date . predecessor ( Date . Unit . MONTH ) . should . eql ( Date . parse ( '2000-05-15' ) ) ;
219+ date . predecessor ( Date . Unit . DAY ) . should . eql ( Date . parse ( '2000-06-14' ) ) ;
220+ } ) ;
221+
222+ it ( "should use the date's finest precision when precision is not specified" , ( ) => {
223+ Date . parse ( '2000-06-15' ) . predecessor ( ) . should . eql ( Date . parse ( '2000-06-14' ) ) ;
224+ Date . parse ( '2000-06' ) . predecessor ( ) . should . eql ( Date . parse ( '2000-05' ) ) ;
225+ Date . parse ( '2000' ) . predecessor ( ) . should . eql ( Date . parse ( '1999' ) ) ;
226+ } ) ;
227+ } ) ;
228+
199229describe ( 'Date.differenceBetween' , ( ) => {
200230 it ( 'should return null if passed a non-Date object' , ( ) => {
201231 const a = Date . parse ( '2018-01-23' ) ;
0 commit comments