mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-08-20 12:20:17 +08:00
add some moment helpers for Jasmine testing
This commit is contained in:
@@ -16,6 +16,7 @@ module.exports = function(config) {
|
||||
{ pattern: 'lib/jquery-simulate/jquery.simulate.js', watched: false },
|
||||
{ pattern: 'lib/jasmine-jquery/lib/jasmine-jquery.js', watched: false },
|
||||
{ pattern: 'lib/jasmine-fixture/dist/jasmine-fixture.js', watched: false },
|
||||
'tests/lib/jasmine-ext.js',
|
||||
'build/out/fullcalendar.js',
|
||||
'build/out/fullcalendar.css',
|
||||
'tests/base.css',
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-button-next').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate.format()).toEqual('2010-03-01');
|
||||
expect(newDate).toEqualMoment('2010-03-01');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-button-prev').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate.format()).toEqual('2010-01-01');
|
||||
expect(newDate).toEqualMoment('2010-01-01');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-button-prevYear').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate.format()).toEqual('2009-02-01');
|
||||
expect(newDate).toEqualMoment('2009-02-01');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-button-nextYear').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate.format()).toEqual('2011-02-01');
|
||||
expect(newDate).toEqualMoment('2011-02-01');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-button-today').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate.format()).toEqual(moment().format());
|
||||
expect(newDate).toEqualNow();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
beforeEach(function() {
|
||||
this.addMatchers({
|
||||
toEqualMoment: function(expected) {
|
||||
return $.fullCalendar.moment(this.actual).format() ===
|
||||
$.fullCalendar.moment(expected).format();
|
||||
},
|
||||
toEqualNow: function() {
|
||||
return Math.abs(
|
||||
$.fullCalendar.moment(this.actual) -
|
||||
new Date()
|
||||
) < 1000; // within a second of current datetime
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user