@rasifix/orienteering-utils 1.0.6 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,102 +0,0 @@
1
- var { parse } = require('../lib/oware');
2
- var { RankingBuilder } = require('../lib/ranking');
3
- var { readFileSync } = require('fs');
4
- var should = require('chai').should();
5
-
6
- require.extensions['.csv'] = function (module, filename) {
7
- module.exports = readFileSync(filename, 'cp1252');
8
- };
9
-
10
- var words = readFileSync('./test/butterfly-oware.csv', 'utf-8');
11
- var assert = require('assert');
12
-
13
- describe('builder', function() {
14
- var event;
15
-
16
- before(function() {
17
- event = parse(words);
18
- });
19
-
20
- describe('#parse()', function() {
21
-
22
- it('should return parsed event', function() {
23
- event.should.be.an('object');
24
- });
25
-
26
- it('should have two categories', function() {
27
- console.log(event.categories.length);
28
- event.categories.length.should.equal(2);
29
- });
30
-
31
- describe('parsed ranking', function() {
32
- describe('category L', function() {
33
- var builder;
34
-
35
- before(function() {
36
- let category = event.categories.find(category => category.name === 'L');
37
- builder = new RankingBuilder(category.runners);
38
- });
39
-
40
- it('should have category L with 4 courses', function() {
41
- builder.courses.should.be.an('array');
42
- builder.courses.length.should.equal(4);
43
- });
44
-
45
- it('should have course 0', function() {
46
- builder.courses[0].code.should.equal('St,31,33,34,35,36,39,34,37,38,39,40,41,44,46,47,48,49,50,52,54,55,49,53,51,54,49,45,43,42,38,36,Zi');
47
- builder.courses[0].runners.length.should.equal(8);
48
- builder.courses[0].runners.should.eql([79, 81, 84, 92, 94, 95, 98, 101]);
49
- });
50
-
51
- it('should have course 1', function() {
52
- builder.courses[1].code.should.equal('St,31,33,34,37,38,39,34,35,36,39,40,41,44,46,47,48,49,50,52,54,55,49,53,51,54,49,45,43,42,38,36,Zi');
53
- builder.courses[1].runners.length.should.equal(11);
54
- builder.courses[1].runners.should.eql([80, 83, 85, 87, 90, 102, 104, 105, 108, 109, 110]);
55
- });
56
-
57
- it('should have course 2', function() {
58
- builder.courses[2].code.should.equal('St,31,33,34,37,38,39,34,35,36,39,40,41,44,46,47,48,49,53,51,54,49,50,52,54,55,49,45,43,42,38,36,Zi');
59
- builder.courses[2].runners.length.should.equal(11);
60
- builder.courses[2].runners.should.eql([82, 91, 96, 99, 100, 103, 106, 107, 114, 115, 116]);
61
- });
62
-
63
- it('should have course 3', function() {
64
- builder.courses[3].code.should.equal('St,31,33,34,35,36,39,34,37,38,39,40,41,44,46,47,48,49,53,51,54,49,50,52,54,55,49,45,43,42,38,36,Zi');
65
- builder.courses[3].runners.length.should.equal(8);
66
- builder.courses[3].runners.should.eql([86, 88, 89, 93, 97, 111, 112, 113]);
67
- });
68
-
69
- it('should produce ranking', function() {
70
- let ranking = builder.getRanking();
71
- });
72
- });
73
-
74
- describe('category K', function() {
75
- var builder;
76
-
77
- before(function() {
78
- let category = event.categories.find(category => category.name === 'K');
79
- builder = new RankingBuilder(category.runners);
80
- });
81
-
82
- it('should have category K with 2 courses', function() {
83
- builder.courses.length.should.equal(2);
84
- });
85
-
86
- it('should have course 0', function() {
87
- builder.courses[0].code.should.equal('St,32,33,40,41,43,46,47,48,49,50,52,54,49,55,54,49,45,44,42,38,39,35,Zi');
88
- builder.courses[0].runners.length.should.equal(40);
89
- builder.courses[0].runners.should.eql([1, 6, 7, 9, 11, 13, 14, 16, 18, 19, 20, 21, 22, 23, 26, 29, 31, 32, 33, 36, 38, 41, 45, 46, 48, 49, 51, 55, 56, 62, 63, 66, 68, 69, 70, 72, 73, 74, 77, 78]);
90
- });
91
-
92
- it('should have course 1', function() {
93
- builder.courses[1].code.should.equal('St,32,33,40,41,43,46,47,48,49,55,54,49,50,52,54,49,45,44,42,38,39,35,Zi');
94
- builder.courses[1].runners.length.should.equal(38);
95
- builder.courses[1].runners.should.eql([2, 3, 4, 5, 8, 10, 12, 15, 17, 24, 25, 27, 28, 30, 34, 35, 37, 39, 40, 42, 43, 44, 47, 50, 52, 53, 54, 57, 58, 59, 60, 61, 64, 65, 67, 71, 75, 76]);
96
- });
97
-
98
- });
99
- });
100
-
101
- });
102
- });
package/test/solv-test.js DELETED
@@ -1,68 +0,0 @@
1
- var { parse } = require('../lib/solv');
2
- var { readFileSync } = require('fs');
3
- var should = require('chai').should();
4
-
5
- require.extensions['.csv'] = function (module, filename) {
6
- module.exports = readFileSync(filename, 'cp1252');
7
- };
8
-
9
- var words = readFileSync('./test/solv.csv', 'utf-8');
10
-
11
- var assert = require('assert');
12
-
13
- describe('solv', function() {
14
- var event;
15
-
16
- before(function() {
17
- event = parse(words);
18
- });
19
-
20
- describe('#parse()', function() {
21
-
22
- it('should return parsed event', function() {
23
- event.should.be.an('object');
24
- });
25
-
26
- it('should be named Anonymous Event', function() {
27
- event.name.should.be.an('string');
28
- event.name.should.equal('Anonymous Event');
29
- });
30
-
31
- it('should have a map name', function() {
32
- event.map.should.be.an('string');
33
- event.map.should.equal('Unknown Map');
34
- });
35
-
36
- it('should have an event date', function() {
37
- event.date.should.equal('');
38
- });
39
-
40
- it('should have a start time', function() {
41
- event.startTime.should.equal('');
42
- });
43
-
44
- it('should have 46 categories', function() {
45
- event.categories.length.should.equal(46);
46
- });
47
-
48
- describe('category K', function() {
49
- var category;
50
-
51
- before(function() {
52
- category = event.categories[0];
53
- });
54
-
55
- it('should have a category HE with 58 runners', function() {
56
- category.should.be.an('object');
57
- category.name.should.equal('HE');
58
- category.runners.length.should.equal(58);
59
- });
60
-
61
- it('should have a runner named Elin Widemar at rank 1', function() {
62
- var runner = category.runners[0];
63
- runner.fullName.should.equal('Elin Widemar');
64
- runner.rank.should.equal(1);
65
- });
66
- });
67
- });
68
- });