@@ -107,6 +107,106 @@ QUnit.test('getIntervalByString second', function(assert) {
107107 assert . deepEqual ( this . getDateIntervalByString ( 'second' ) , { seconds : 1 } ) ;
108108} ) ;
109109
110+ QUnit . module ( 'getFirstMonthDate' , ( ) => {
111+ QUnit . test ( 'should return same month first date when offset is not provided' , function ( assert ) {
112+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 11 , 15 ) ) ;
113+
114+ assert . deepEqual ( newDate , new Date ( 2025 , 11 , 1 ) ) ;
115+ } ) ;
116+
117+ QUnit . test ( 'should return same month first date when offset is 0' , function ( assert ) {
118+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 11 , 15 ) , 0 ) ;
119+
120+ assert . deepEqual ( newDate , new Date ( 2025 , 11 , 1 ) ) ;
121+ } ) ;
122+
123+ QUnit . test ( 'should decrease month correctly' , function ( assert ) {
124+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 11 , 31 ) , - 1 ) ;
125+
126+ assert . deepEqual ( newDate , new Date ( 2025 , 10 , 1 ) ) ;
127+ } ) ;
128+
129+ QUnit . test ( 'should increase month correctly' , function ( assert ) {
130+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 8 , 30 ) , 1 ) ;
131+
132+ assert . deepEqual ( newDate , new Date ( 2025 , 9 , 1 ) ) ;
133+ } ) ;
134+
135+ QUnit . test ( 'should decrease month correctly when offset is less than -1' , function ( assert ) {
136+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 11 , 15 ) , - 2 ) ;
137+
138+ assert . deepEqual ( newDate , new Date ( 2025 , 9 , 1 ) ) ;
139+ } ) ;
140+
141+ QUnit . test ( 'should increase month correctly when offset is greater than 1' , function ( assert ) {
142+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 8 , 15 ) , 2 ) ;
143+
144+ assert . deepEqual ( newDate , new Date ( 2025 , 10 , 1 ) ) ;
145+ } ) ;
146+
147+ QUnit . test ( 'should assign correct new date when current year is increased' , function ( assert ) {
148+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 11 , 15 ) , 1 ) ;
149+
150+ assert . deepEqual ( newDate , new Date ( 2026 , 0 , 1 ) ) ;
151+ } ) ;
152+
153+ QUnit . test ( 'should assign correct new date when current year is decreased' , function ( assert ) {
154+ const newDate = dateUtils . getFirstMonthDate ( new Date ( 2025 , 0 , 1 ) , - 1 ) ;
155+
156+ assert . deepEqual ( newDate , new Date ( 2024 , 11 , 1 ) ) ;
157+ } ) ;
158+ } ) ;
159+
160+ QUnit . module ( 'getLastMonthDate' , ( ) => {
161+ QUnit . test ( 'should return same month last date when offset is not provided' , function ( assert ) {
162+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 11 , 15 ) ) ;
163+
164+ assert . deepEqual ( newDate , new Date ( 2025 , 11 , 31 ) ) ;
165+ } ) ;
166+
167+ QUnit . test ( 'should return same month last date when offset is 0' , function ( assert ) {
168+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 11 , 15 ) , 0 ) ;
169+
170+ assert . deepEqual ( newDate , new Date ( 2025 , 11 , 31 ) ) ;
171+ } ) ;
172+
173+ QUnit . test ( 'should decrease month correctly' , function ( assert ) {
174+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 11 , 31 ) , - 1 ) ;
175+
176+ assert . deepEqual ( newDate , new Date ( 2025 , 10 , 30 ) ) ;
177+ } ) ;
178+
179+ QUnit . test ( 'should increase month correctly' , function ( assert ) {
180+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 8 , 30 ) , 1 ) ;
181+
182+ assert . deepEqual ( newDate , new Date ( 2025 , 9 , 31 ) ) ;
183+ } ) ;
184+
185+ QUnit . test ( 'should decrease month correctly when offset is less than -1' , function ( assert ) {
186+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 11 , 15 ) , - 2 ) ;
187+
188+ assert . deepEqual ( newDate , new Date ( 2025 , 9 , 31 ) ) ;
189+ } ) ;
190+
191+ QUnit . test ( 'should increase month correctly when offset is greater than 1' , function ( assert ) {
192+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 8 , 15 ) , 2 ) ;
193+
194+ assert . deepEqual ( newDate , new Date ( 2025 , 10 , 30 ) ) ;
195+ } ) ;
196+
197+ QUnit . test ( 'should assign correct new date when current year is increased' , function ( assert ) {
198+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 11 , 15 ) , 1 ) ;
199+
200+ assert . deepEqual ( newDate , new Date ( 2026 , 0 , 31 ) ) ;
201+ } ) ;
202+
203+ QUnit . test ( 'should assign correct new date when current year is decreased' , function ( assert ) {
204+ const newDate = dateUtils . getLastMonthDate ( new Date ( 2025 , 0 , 1 ) , - 1 ) ;
205+
206+ assert . deepEqual ( newDate , new Date ( 2024 , 11 , 31 ) ) ;
207+ } ) ;
208+ } ) ;
209+
110210QUnit . test ( 'add negative Interval number' , function ( assert ) {
111211 // arrange, act
112212 const newNumber = dateUtils . addInterval ( 11 , 5 , true ) ;
0 commit comments