import assert from 'assert' ; import eachWeekendOfInterval from '.' ; describe ( 'eachWeekendOfInterval' , ( ) => { it ( 'returns all weekends within the interval' , ( ) => { const result = eachWeekendOfInterval ( { start : new Date ( 2018 , 8 , 17 ) , end : new Date ( 2018 , 8 , 30 ) , } ) ; assert . deepStrictEqual ( result , [ new Date ( 2018 , 8 , 22 ) , new Date ( 2018 , 8 , 23 ) , new Date ( 2018 , 8 , 29 ) , new Date ( 2018 , 8 , 30 ) , ] ) ; } ) ; it ( 'returns all weekends within the interval when starting on a weekend' , ( ) => { const result = eachWeekendOfInterval ( { start : new Date ( 2018 , 8 , 22 ) , end : new Date ( 2018 , 8 , 30 ) , } ) ; assert . deepStrictEqual ( result , [ new Date ( 2018 , 8 , 22 ) , new Date ( 2018 , 8 , 23 ) , new Date ( 2018 , 8 , 29 ) , new Date ( 2018 , 8 , 30 ) , ] ) ; } ) ; it ( 'throws `RangeError` invalid interval start date is used' , ( ) => { const block = eachWeekendOfInterval . bind ( null , { start : new Date ( NaN ) , end : new Date ( 2019 , 11 , 31 ) , } ) ; assert . throws ( block , RangeError ) ; } ) ; it ( 'throws `RangeError` invalid interval end date is used' , ( ) => { const block = eachWeekendOfInterval . bind ( null , { start : new Date ( 2019 , 0 , 1 ) , end : new Date ( NaN ) , } ) ; assert . throws ( block , RangeError ) ; } ) ; it ( 'throws TypeError exception if passed less than 1 argument' , ( ) => { assert . throws ( eachWeekendOfInterval , TypeError ) ; } ) ; it ( 'throws `RangeError` if start of an interval is after its end' , ( ) => { const block = eachWeekendOfInterval . bind ( null , { start : new Date ( 2018 , 8 , 25 ) , end : new Date ( 2018 , 8 , 6 ) , } ) ; assert . throws ( block , RangeError ) ; } ) ; } ) ;