Skip to content

Commit 0957b1e

Browse files
Tests added
Incorrect speed sign after rotation through zero degrees fixed
1 parent 7156853 commit 0957b1e

File tree

6 files changed

+146
-40
lines changed

6 files changed

+146
-40
lines changed

Gruntfile.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ module.exports = function(grunt) {
77
'dist/propeller.min.js': ['src/propeller.js']
88
}
99
}
10+
},
11+
karma: {
12+
unit: {
13+
configFile: 'karma.conf.js'
14+
}
1015
}
11-
1216
});
1317

18+
grunt.loadNpmTasks('grunt-karma');
1419
grunt.loadNpmTasks('grunt-contrib-uglify');
1520

1621
grunt.registerTask('default', 'uglify');

dist/propeller.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

karma.conf.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Karma configuration
2+
// Generated on Sat Feb 01 2014 21:21:47 GMT+0100 (CET)
3+
4+
module.exports = function(config) {
5+
config.set({
6+
7+
// base path, that will be used to resolve files and exclude
8+
basePath: '',
9+
10+
11+
// frameworks to use
12+
frameworks: ['jasmine'],
13+
14+
15+
// list of files / patterns to load in the browser
16+
files: [
17+
'src/*.js',
18+
'spec/*.js'
19+
],
20+
21+
22+
// list of files to exclude
23+
exclude: [
24+
25+
],
26+
27+
28+
// test results reporter to use
29+
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
30+
reporters: ['progress'],
31+
32+
33+
// web server port
34+
port: 9876,
35+
36+
37+
// enable / disable colors in the output (reporters and logs)
38+
colors: true,
39+
40+
41+
// level of logging
42+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
43+
logLevel: config.LOG_INFO,
44+
45+
46+
// enable / disable watching file and executing tests whenever any file changes
47+
autoWatch: true,
48+
49+
50+
// Start these browsers, currently available:
51+
// - Chrome
52+
// - ChromeCanary
53+
// - Firefox
54+
// - Opera (has to be installed with `npm install karma-opera-launcher`)
55+
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
56+
// - PhantomJS
57+
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
58+
browsers: ['PhantomJS'],
59+
60+
61+
// If browser does not capture in given timeout [ms], kill it
62+
captureTimeout: 60000,
63+
64+
65+
// Continuous Integration mode
66+
// if true, it capture browsers, run tests and exit
67+
singleRun: false
68+
});
69+
};

package.json

+35-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
{
2-
"name": "Propeller",
3-
"version": "0.3.0",
4-
"description": "JavaScript library to rotate elements by mouse with inertia or without it.",
5-
"main": "index.js",
6-
"directories": {
7-
"example": "example"
8-
},
9-
"scripts": {
10-
"test": "echo \"Error: no test specified\" && exit 1"
11-
},
12-
"repository": {
13-
"type": "git",
14-
"url": "https://github.com/PixelsCommander/Propeller.git"
15-
},
16-
"author": "Denis Radin",
17-
"license": "MIT",
18-
"bugs": {
19-
"url": "https://github.com/PixelsCommander/Propeller/issues"
20-
},
21-
"homepage": "https://github.com/PixelsCommander/Propeller",
22-
"devDependencies": {
23-
"grunt": "~0.4.2",
24-
"grunt-contrib-uglify": "~0.2.7"
25-
}
2+
"name": "Propeller",
3+
"version": "0.3.0",
4+
"description": "JavaScript library to rotate elements by mouse with inertia or without it.",
5+
"main": "index.js",
6+
"directories": {
7+
"example": "example"
8+
},
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/PixelsCommander/Propeller.git"
15+
},
16+
"author": "Denis Radin",
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/PixelsCommander/Propeller/issues"
20+
},
21+
"homepage": "https://github.com/PixelsCommander/Propeller",
22+
"devDependencies": {
23+
"grunt": "~0.4.2",
24+
"grunt-contrib-uglify": "~0.2.7",
25+
"karma-script-launcher": "~0.1.0",
26+
"karma-chrome-launcher": "~0.1.2",
27+
"karma-firefox-launcher": "~0.1.3",
28+
"karma-html2js-preprocessor": "~0.1.0",
29+
"karma-jasmine": "~0.1.5",
30+
"requirejs": "~2.1.10",
31+
"karma-requirejs": "~0.2.1",
32+
"karma-coffee-preprocessor": "~0.1.2",
33+
"karma-phantomjs-launcher": "~0.1.1",
34+
"karma": "~0.10.9",
35+
"grunt-karma": "~0.6.2"
36+
}
2637
}

spec/tests.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var propeller = new Propeller(document.body);
2+
3+
describe("Angle transformation routines", function() {
4+
it("should be able to determine shortest angle between two angles", function() {
5+
expect(propeller.differenceBetweenAngles(45, 0)).toEqual(45);
6+
});
7+
});
8+
9+
describe("Defaults configuration", function() {
10+
it("should have minimal inertia and minimal angle change be set from defaults", function() {
11+
expect(propeller.minimalAngleChange).toEqual(0.1);
12+
expect(propeller.minimalInertia).toEqual(0.001);
13+
});
14+
});
15+
16+
describe("Element coordinates detection", function() {
17+
it("should return 0 for document.body.left", function() {
18+
expect(propeller.getViewOffset().x).toEqual(0);
19+
});
20+
});

0 commit comments

Comments
 (0)