Skip to content

Commit 101e226

Browse files
author
LazyTesting
committed
added engine for total downhill time
1 parent 4eac4e5 commit 101e226

File tree

4 files changed

+1753
-0
lines changed

4 files changed

+1753
-0
lines changed

engine/total-downhill-time/app.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const convertGPX = require('../../core/convert-gpx-data');
2+
const timeDifference = require('../../core/calculate-time-difference');
3+
const filterDownhill = require('../../core/filter-downhill');
4+
5+
/**
6+
* returns the total downhill time of the track
7+
* @param {String} gpxContent - gpx document
8+
* @returns {Number} time - elapsed time in seconds
9+
*/
10+
const get = function(gpxContent) {
11+
const points = convertGPX(gpxContent);
12+
13+
return filterDownhill(points, timeDifference);
14+
};
15+
16+
module.exports = get;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "total-downhill-time",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "app.js",
6+
"scripts": {
7+
"test": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec spec"
8+
},
9+
"author": "Maarten Groeneweg",
10+
"license": "ISC",
11+
"devDependencies": {
12+
"istanbul": "^0.4.5",
13+
"mocha": "^3.1.2"
14+
}
15+
}

engine/total-downhill-time/spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const time = require('./app.js');
2+
const path = require('path');
3+
const fs = require('fs');
4+
const assert = require('assert');
5+
6+
describe('total downhill time', () => {
7+
it('should return a positive number', () => {
8+
const filePath = path.join(__dirname, '/test/data.gpx');
9+
const gpx = fs.readFileSync(filePath, 'utf8');
10+
const result = time(gpx);
11+
12+
assert.notEqual(result, null);
13+
});
14+
});

0 commit comments

Comments
 (0)