Permalink
Browse files

Added first test case

  • Loading branch information...
1 parent b61078a commit 1adc66b363b1bed780714b6661fdd54e6793a51a @schickling schickling committed May 22, 2013
Showing with 9,096 additions and 33 deletions.
  1. +7 −10 Gruntfile.js
  2. +1 −1 package.json
  3. +70 −0 test/dragdrop.js
  4. +8,755 −0 test/lib/jquery.js
  5. +223 −0 test/resources/simple.html
  6. +40 −0 test/resources/style.css
  7. +0 −22 test/test.js
View
@@ -30,26 +30,23 @@ module.exports = function (grunt) {
}
},
- casper: {
- options: {
- test: true
- },
- test: {
- src: ['test/test.js']
- }
+ casperjs: {
+ files: ['test/*.js']
}
});
- grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-casper');
+ grunt.loadNpmTasks('grunt-contrib-connect');
+ grunt.loadNpmTasks('grunt-casperjs');
+
grunt.registerTask('test', [
'jshint',
'connect:server',
- 'casper'
+ 'casperjs'
]);
+
grunt.registerTask('default', [
'test'
]);
View
@@ -6,7 +6,7 @@
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.5.2",
"grunt-contrib-connect": "~0.2.0",
- "grunt-casper": "~0.1.1"
+ "grunt-casperjs": "~1.0.6"
},
"scripts": {
"test": "grunt test --verbose"
View
@@ -0,0 +1,70 @@
+var casper = require('casper').create();
+
+// set up
+casper.start();
+casper.options.clientScripts = ['./test/lib/jquery.js'];
+casper.viewport(500, 500);
+
+
+// add helper methods
+casper.getScrollTop = function () {
+ return this.evaluate(function () {
+ return $('#overscroll').scrollTop();
+ });
+};
+
+casper.getScrollLeft = function () {
+ return this.evaluate(function () {
+ return $('#overscroll').scrollLeft();
+ });
+};
+
+casper.thenOpen('http://localhost:9000/test/resources/simple.html', function () {
+
+ casper.test.comment('test scroll up');
+
+ this.test.assertEquals(this.getScrollTop(), 0, 'init - check top');
+ this.test.assertEquals(this.getScrollLeft(), 0, 'init - check left');
+
+ this.mouse.down(0, 400);
+ this.mouse.move(0, 300);
+ this.mouse.up(0, 300);
+
+ this.test.assertEquals(this.getScrollTop(), 100, 'dragged 100 px up - check top');
+ this.test.assertEquals(this.getScrollLeft(), 0, 'dragged 100 px up - check left');
+
+});
+
+casper.thenOpen('http://localhost:9000/test/resources/simple.html', function () {
+
+ casper.test.comment('test scroll left');
+
+ this.test.assertEquals(this.getScrollTop(), 0, 'init - check top');
+ this.test.assertEquals(this.getScrollLeft(), 0, 'init - check left');
+
+ this.mouse.down(400, 0);
+ this.mouse.move(300, 0);
+ this.mouse.up(300, 0);
+
+ this.test.assertEquals(this.getScrollTop(), 0, 'dragged 100 px left - check top');
+ this.test.assertEquals(this.getScrollLeft(), 100, 'dragged 100 px left - check left');
+
+});
+
+casper.thenOpen('http://localhost:9000/test/resources/simple.html', function () {
+
+ casper.test.comment('test scroll up+left');
+
+ this.test.assertEquals(this.getScrollTop(), 0, 'init - check top');
+ this.test.assertEquals(this.getScrollLeft(), 0, 'init - check left');
+
+ this.mouse.down(400, 400);
+ this.mouse.move(300, 300);
+ this.mouse.up(300, 300);
+
+ this.test.assertEquals(this.getScrollTop(), 100, 'dragged 100 px up+left - check top');
+ this.test.assertEquals(this.getScrollLeft(), 100, 'dragged 100 px up+left - check left');
+
+});
+
+casper.run();
Oops, something went wrong.

0 comments on commit 1adc66b

Please sign in to comment.