latest jasmine-jquery and jasmine-fixture

This commit is contained in:
Adam Shaw
2014-03-15 11:39:16 -07:00
parent a1c4f11f48
commit ceb13bb0c5
4 changed files with 33 additions and 21 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
"jquery": "~1.10.2",
"jquery-ui": "~1.10.3",
"jquery-simulate": "*",
"jasmine-jquery": "~1.7.0",
"jasmine-fixture": "~1.0.8"
"jasmine-jquery": "~2.0.3",
"jasmine-fixture": "~1.2.0"
}
}
+2 -2
View File
@@ -48,9 +48,9 @@ If you want to clean up the generated files, run:
Automated Testing
-----------------
To run automated tests, you must first install [karma] globally:
To run automated tests, you must first install [karma] globally, as well as some karma plugins:
npm install -g karma
npm install -g karma karma-jasmine karma-phantomjs-launcher
Then, assuming all your source files have been built (via `grunt dev` or `watch`), you can run the tests from a browser:
+9 -9
View File
@@ -19,15 +19,15 @@ describe('isRTL tests', function() {
});
it('should have prev in left', function() {
var fcHeaderLeft = $(cal).find('.fc-header-left')[0];
expect(fcHeaderLeft).toContain('.fc-button-prev');
expect(fcHeaderLeft).toContainElement('.fc-button-prev');
});
it('should have today in center', function() {
var fcHeaderCenter = $(cal).find('.fc-header-center')[0];
expect(fcHeaderCenter).toContain('.fc-button-today');
expect(fcHeaderCenter).toContainElement('.fc-button-today');
});
it('should have next in right', function() {
var fcHeaderRight = $(cal).find('.fc-header-right')[0];
expect(fcHeaderRight).toContain('.fc-button-next');
expect(fcHeaderRight).toContainElement('.fc-button-next');
});
});
@@ -46,15 +46,15 @@ describe('isRTL tests', function() {
});
it('should have prev in left', function() {
var fcHeaderLeft = $(cal).find('.fc-header-left')[0];
expect(fcHeaderLeft).toContain('.fc-button-prev');
expect(fcHeaderLeft).toContainElement('.fc-button-prev');
});
it('should have today in center', function() {
var fcHeaderCenter = $(cal).find('.fc-header-center')[0];
expect(fcHeaderCenter).toContain('.fc-button-today');
expect(fcHeaderCenter).toContainElement('.fc-button-today');
});
it('should have next in right', function() {
var fcHeaderRight = $(cal).find('.fc-header-right')[0];
expect(fcHeaderRight).toContain('.fc-button-next');
expect(fcHeaderRight).toContainElement('.fc-button-next');
});
});
@@ -73,15 +73,15 @@ describe('isRTL tests', function() {
});
it('should have prev in left', function() {
var fcHeaderLeft = $(cal).find('.fc-header-left')[0];
expect(fcHeaderLeft).toContain('.fc-button-prev');
expect(fcHeaderLeft).toContainElement('.fc-button-prev');
});
it('should have today in center', function() {
var fcHeaderCenter = $(cal).find('.fc-header-center')[0];
expect(fcHeaderCenter).toContain('.fc-button-today');
expect(fcHeaderCenter).toContainElement('.fc-button-today');
});
it('should have next in right', function() {
var fcHeaderRight = $(cal).find('.fc-header-right')[0];
expect(fcHeaderRight).toContain('.fc-button-next');
expect(fcHeaderRight).toContainElement('.fc-button-next');
});
});
+20 -8
View File
@@ -1,15 +1,27 @@
beforeEach(function() {
this.addMatchers({
toEqualMoment: function(expected) {
return $.fullCalendar.moment(this.actual).format() ===
$.fullCalendar.moment(expected).format();
jasmine.addMatchers({
toEqualMoment: function() {
return {
compare: function(actual, expected) {
return {
pass: $.fullCalendar.moment(actual).format() ===
$.fullCalendar.moment(expected).format()
};
}
};
},
toEqualNow: function() {
return Math.abs(
$.fullCalendar.moment(this.actual) -
new Date()
) < 1000; // within a second of current datetime
return {
compare: function(actual) {
return {
pass: Math.abs(
$.fullCalendar.moment(actual) -
new Date()
) < 1000 // within a second of current datetime
};
}
};
}
});
});