• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nightscout / cgm-remote-monitor / 5637

pending completion
5637

push

travis-ci

web-flow
Merge pull request #1896 from ps2/loop-plugin

Loop plugin

174 of 174 new or added lines in 1 file covered. (100.0%)

6632 of 8664 relevant lines covered (76.55%)

9988.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/lib/plugins/direction.js
1
'use strict';
2

3
var _ = require('lodash');
4✔
4

5
function init() {
4✔
6

7
  var direction = {
218✔
8
    name: 'direction'
9
    , label: 'BG direction'
10
    , pluginType: 'bg-status'
11
  };
12

13
  direction.setProperties = function setProperties (sbx) {
218✔
14
    sbx.offerProperty('direction', function setDirection ( ) {
63✔
15
      if (sbx.data.inRetroMode && !sbx.isCurrent(sbx.lastSGVEntry())) {
63✔
16
        return undefined;
×
17
      } else {
18
        return direction.info(sbx.lastSGVEntry());
63✔
19
      }
20
    });
21
  };
22

23
  direction.updateVisualisation = function updateVisualisation (sbx) {
218✔
24
    var prop = sbx.properties.direction;
40✔
25

26
    if (!prop || !prop.value) {
40✔
27
      sbx.pluginBase.updatePillText(direction, {
×
28
        hide: true
29
      });
30
    } else {
31
      if (sbx.lastSGVMgdl() < 39) {
40✔
32
        prop.value = 'CGM ERROR';
×
33
        prop.label = '✖';
×
34
      }
35

36
      sbx.pluginBase.updatePillText(direction, {
40✔
37
        label: prop && prop.label + '&#xfe0e;'
38
        , directHTML: true
39
      });
40
    }
41
  };
42

43
  direction.info = function info(sgv) {
218✔
44
    var result = { display: null };
159✔
45

46
    if (!sgv) { return result; }
159✔
47

48
    result.value = sgv.direction;
147✔
49
    result.label = directionToChar(result.value);
147✔
50
    result.entity = charToEntity(result.label);
147✔
51

52
    return result;
147✔
53
  };
54

55
  var dir2Char = {
218✔
56
    NONE: '⇼'
57
    , DoubleUp: '⇈'
58
    , SingleUp: '↑'
59
    , FortyFiveUp: '↗'
60
    , Flat: '→'
61
    , FortyFiveDown: '↘'
62
    , SingleDown: '↓'
63
    , DoubleDown: '⇊'
64
    , 'NOT COMPUTABLE': '-'
65
    , 'RATE OUT OF RANGE': '⇕'
66
  };
67

68
  function charToEntity(char) {
4✔
69
    return char && char.length && '&#' + char.charCodeAt(0) + ';';
147✔
70
  }
71

72
  function directionToChar(direction) {
4✔
73
    return dir2Char[direction] || '-';
147✔
74
  }
75

76
  return direction;
218✔
77

78
}
79

80
module.exports = init;
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2024 Coveralls, Inc