Permalink
Browse files

sgp4 Jasmine test is written.

  • Loading branch information...
1 parent 7c4d23c commit ab34e470c377ead9917fbb2478e537e7881d277b @ezze ezze committed Jun 19, 2015
Showing with 301 additions and 4 deletions.
  1. +3 −0 .bowerrc
  2. +1 −0 .gitignore
  3. +3 −1 .jshintrc
  4. +8 −2 Gruntfile.js
  5. +26 −0 bower.json
  6. +7 −0 grunt/jshint.js
  7. +35 −0 grunt/karma.js
  8. +9 −1 package.json
  9. +27 −0 test/main.js
  10. +38 −0 test/satellite.spec.js
  11. +144 −0 test/sgp4.json
View
@@ -0,0 +1,3 @@
+{
+ "directory": "lib"
+}
View
@@ -1,3 +1,4 @@
.idea
node_modules
+/lib
/sgp4_verification/lib/sgp4
View
@@ -8,9 +8,11 @@
"globals": {
// RequireJS
"define": false,
- "require": false
+ "require": false,
+ "requirejs": false
},
"indent": 4,
+ "jasmine": true,
"maxdepth": 4,
"maxlen": 120,
"newcap": false,
View
@@ -11,15 +11,21 @@ module.exports = function(grunt) {
}
});
- grunt.registerTask('build', [
+ grunt.registerTask('test', [
'jshint',
+ 'karma'
+ ]);
+
+ grunt.registerTask('build', [
+ 'jshint:gruntfile',
+ 'jshint:library',
'requirejs',
'copy'
]);
grunt.registerTask('rebuild', [
'clean',
- 'build',
+ 'build'
]);
grunt.registerTask('default', [
View
@@ -0,0 +1,26 @@
+{
+ "name": "satellite-js",
+ "version": "1.2.0",
+ "homepage": "https://github.com/shashwatak/satellite-js",
+ "authors": [
+ "Shashwat Kandadai",
+ "Dmitriy Pushkov <ezze@ezze.org>"
+ ],
+ "description": "SGP4/SDP4 calculation library",
+ "main": "src/satellite.js",
+ "keywords": [
+ "sgp4"
+ ],
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "grunt",
+ "node_modules",
+ "lib",
+ "sgp4_verification",
+ "test"
+ ],
+ "devDependencies": {
+ "requirejs-plugins": "~1.0.3"
+ }
+}
View
@@ -20,6 +20,13 @@ module.exports = function(grunt) {
'src/**/*.js'
]
}
+ },
+ test: {
+ files: {
+ src: [
+ 'test/**/*.js'
+ ]
+ }
}
};
};
View
@@ -0,0 +1,35 @@
+/* global module: false */
+module.exports = function(grunt) {
+ 'use strict';
+
+ return {
+ unit: {
+ options: {
+ singleRun: true,
+ frameworks: ['jasmine', 'requirejs'],
+ browsers: ['PhantomJS']
+ },
+ files: [{
+ src: [
+ 'lib/**/*.js'
+ ],
+ included: false
+ }, {
+ src: [
+ 'src/**/*.js'
+ ],
+ included: false
+ }, {
+ src: [
+ 'test/**/*.spec.js',
+ 'test/**/*.json'
+ ],
+ included: false
+ }, {
+ src: [
+ 'test/main.js'
+ ]
+ }]
+ }
+ };
+};
View
@@ -32,9 +32,17 @@
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "~0.6.0",
+ "grunt-contrib-copy": "~0.8.0",
"grunt-contrib-jshint": "~0.11.2",
+ "grunt-karma": "~0.11.0",
"grunt-requirejs": "~0.4.2",
+ "jasmine-core": "~2.3.4",
+ "karma": "~0.12.36",
+ "karma-jasmine": "~0.3.5",
+ "karma-phantomjs-launcher": "~0.2.0",
+ "karma-requirejs": "~0.2.2",
"load-grunt-config": "~0.17.1",
- "grunt-contrib-copy": "~0.8.0"
+ "phantomjs": "~1.9.17",
+ "requirejs": "~2.1.18"
}
}
View
@@ -0,0 +1,27 @@
+/* global window: false */
+(function() {
+ 'use strict';
+
+ var specFiles = [];
+ for (var file in window.__karma__.files) {
+ if (/spec\.js$/.test(file)) {
+ specFiles.push(file);
+ }
+ }
+ console.log('Test files loaded: ' + specFiles.length);
+
+ requirejs.config({
+ baseUrl: '/base/src', // Karma serves files from '/base'
+ paths: {
+ test: '../test',
+ lib: '../lib',
+ json: '../lib/requirejs-plugins/src/json',
+ text: '../lib/requirejs-plugins/lib/text'
+ },
+ deps: specFiles // ask Require.js to load all specFiles
+ });
+
+ require(specFiles, function () {
+ window.__karma__.start();
+ });
+})();
@@ -0,0 +1,38 @@
+define([
+ 'satellite',
+ 'json!test/sgp4.json'
+], function(
+ satellite,
+ sgp4data
+) {
+ 'use strict';
+
+ describe('Satellite test suite', function() {
+ it('sgp4', function() {
+ var sgp4, sgp4dataItem,
+ satrec, result,
+ precision = 7;
+
+ for (var i = 0; i < sgp4data.length; i += 1) {
+ sgp4dataItem = sgp4data[i];
+
+ // Fetching satellite record from TLE lines
+ satrec = satellite.twoline2satrec(sgp4dataItem.tleLine1, sgp4dataItem.tleLine2);
+
+ for (var j = 0; j < sgp4dataItem.results.length; j += 1) {
+ result = sgp4dataItem.results[j];
+
+ sgp4 = satellite.sgp4(satrec, result.time);
+
+ expect(sgp4.position.x).toBeCloseTo(result.position.x, precision);
+ expect(sgp4.position.y).toBeCloseTo(result.position.y, precision);
+ expect(sgp4.position.z).toBeCloseTo(result.position.z, precision);
+
+ expect(sgp4.velocity.x).toBeCloseTo(result.velocity.x, precision);
+ expect(sgp4.velocity.y).toBeCloseTo(result.velocity.y, precision);
+ expect(sgp4.velocity.z).toBeCloseTo(result.velocity.z, precision);
+ }
+ }
+ });
+ });
+});
View
@@ -0,0 +1,144 @@
+[
+ {
+ "tleLine1": "1 88888U 80275.98708465 .00073094 13844-3 66816-4 0 8",
+ "tleLine2": "2 88888 72.8435 115.9689 0086731 52.6988 110.5714 16.05824518 105",
+ "results": [
+ {
+ "time": 0.0,
+ "position": {
+ "x": 2328.957357263014,
+ "y": -5995.219305262678,
+ "z": 1720.0073114076358
+ },
+ "velocity": {
+ "x": 2.91207765874696,
+ "y": -0.9834360870126623,
+ "z": -7.090803298325344
+ }
+ },
+ {
+ "time": 360.0,
+ "position": {
+ "x": 2456.089652220053,
+ "y": -6071.940386186373,
+ "z": 1222.9342493789352
+ },
+ "velocity": {
+ "x": 2.6793960876510083,
+ "y": -0.4483139198146117,
+ "z": -7.228781912039579
+ }
+ },
+ {
+ "time": 720.0,
+ "position": {
+ "x": 2567.540106442206,
+ "y": -6112.50918063211,
+ "z": 714.0019601514776
+ },
+ "velocity": {
+ "x": 2.440254031643538,
+ "y": 0.09808220218774294,
+ "z": -7.319952245888289
+ }
+ },
+ {
+ "time": 1080.0,
+ "position": {
+ "x": 2663.062956505525,
+ "y": -6115.492075231422,
+ "z": 196.43997125154644
+ },
+ "velocity": {
+ "x": 2.1961326037094726,
+ "y": 0.6523859581455292,
+ "z": -7.362820741307043
+ }
+ },
+ {
+ "time": 1440.0,
+ "position": {
+ "x": 2742.5231263865253,
+ "y": -6079.683233691672,
+ "z": -326.350514126162
+ },
+ "velocity": {
+ "x": 1.9485119418860857,
+ "y": 1.211042603674053,
+ "z": -7.356193489571535
+ }
+ }
+ ]
+ },
+ {
+ "tleLine1": "1 11801U 80230.29629788 .01431103 00000-0 14311-1 ",
+ "tleLine2": "2 11801 46.7916 230.4354 7318036 47.4722 10.4117 2.28537848 ",
+ "results": [
+ {
+ "time": 0.0,
+ "position": {
+ "x": 7473.3599032879365,
+ "y": 428.90099009406805,
+ "z": 5828.770850028464
+ },
+ "velocity": {
+ "x": 5.10716775131343,
+ "y": 6.444664842035081,
+ "z": -0.18611269941800382
+ }
+ },
+ {
+ "time": 360.0,
+ "position": {
+ "x": -3305.2047838547987,
+ "y": 32410.796658377898,
+ "z": -24697.124806172797
+ },
+ "velocity": {
+ "x": -1.3011409273028303,
+ "y": -1.151318003512851,
+ "z": -0.2833371179184987
+ }
+ },
+ {
+ "time": 720.0,
+ "position": {
+ "x": 14271.309350739291,
+ "y": 24110.459756353135,
+ "z": -4725.760339366821
+ },
+ "velocity": {
+ "x": -0.3205094712462314,
+ "y": 2.6798324974506915,
+ "z": -2.0840523146670265
+ }
+ },
+ {
+ "time": 1080.0,
+ "position": {
+ "x": -9990.126360275444,
+ "y": 22717.081117427293,
+ "z": -23616.76382489919
+ },
+ "velocity": {
+ "x": -1.01667117261397,
+ "y": -2.2902907031491804,
+ "z": 0.7289415577329694
+ }
+ },
+ {
+ "time": 1440.0,
+ "position": {
+ "x": 9787.757441373433,
+ "y": 33753.339067624205,
+ "z": -15030.91096060269
+ },
+ "velocity": {
+ "x": -1.0942645167263871,
+ "y": 0.9235593523204051,
+ "z": -1.5223007481343744
+ }
+ }
+ ]
+ }
+]

0 comments on commit ab34e47

Please sign in to comment.