mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* Adds API to plugin manager that calls plugins to visualize alarms * Refactoring how the translation object is managed after discovering every server-side plugin had it's own instance of the translations and the language code wasn't propagated to any code that generated alarms * Add more missing translations * Some more localization fixes Update Finnish to 100% localized Change Mongo connection to not stop retrying connecting * Better scaling for mmol Fix bug in detecting new BG values * Delta calculation was the wrong way round :D * add missing dutch translations * Have tests bail early & tell Mocha to exit at the end of the run * Try if Travis likes running tests one by one better * Enable blocking IO for Travis
105 lines
3.7 KiB
JavaScript
105 lines
3.7 KiB
JavaScript
'use strict';
|
|
|
|
require('should');
|
|
|
|
describe('BG direction', function ( ) {
|
|
|
|
var now = Date.now();
|
|
|
|
function setupSandbox(data, pluginBase) {
|
|
var ctx = {
|
|
settings: {}
|
|
, pluginBase: pluginBase || {}
|
|
};
|
|
|
|
ctx.language = require('../lib/language')();
|
|
|
|
var sandbox = require('../lib/sandbox')();
|
|
return sandbox.clientInit(ctx, Date.now(), data);
|
|
}
|
|
|
|
it('set the direction property - Flat', function (done) {
|
|
var sbx = setupSandbox({sgvs: [{mills: now, direction: 'Flat'}]});
|
|
|
|
sbx.offerProperty = function mockedOfferProperty (name, setter) {
|
|
name.should.equal('direction');
|
|
var result = setter();
|
|
result.value.should.equal('Flat');
|
|
result.label.should.equal('→');
|
|
result.entity.should.equal('→');
|
|
done();
|
|
};
|
|
|
|
var direction = require('../lib/plugins/direction')();
|
|
direction.setProperties(sbx);
|
|
|
|
});
|
|
|
|
it('set the direction property Double Up', function (done) {
|
|
var sbx = setupSandbox({sgvs: [{mills: now, direction: 'DoubleUp'}]});
|
|
|
|
sbx.offerProperty = function mockedOfferProperty (name, setter) {
|
|
name.should.equal('direction');
|
|
var result = setter();
|
|
result.value.should.equal('DoubleUp');
|
|
result.label.should.equal('⇈');
|
|
result.entity.should.equal('⇈');
|
|
done();
|
|
};
|
|
|
|
var direction = require('../lib/plugins/direction')();
|
|
direction.setProperties(sbx);
|
|
|
|
});
|
|
|
|
it('set a pill to the direction', function (done) {
|
|
var pluginBase = {
|
|
updatePillText: function mockedUpdatePillText (plugin, options) {
|
|
options.label.should.equal('→︎');
|
|
done();
|
|
}
|
|
};
|
|
|
|
var sbx = setupSandbox({sgvs: [{mills: now, direction: 'Flat'}]}, pluginBase);
|
|
var direction = require('../lib/plugins/direction')();
|
|
direction.setProperties(sbx);
|
|
direction.updateVisualisation(sbx);
|
|
});
|
|
|
|
it('get the info for a direction', function () {
|
|
var direction = require('../lib/plugins/direction')();
|
|
|
|
direction.info({mills: now, direction: 'NONE'}).label.should.equal('⇼');
|
|
direction.info({mills: now, direction: 'NONE'}).entity.should.equal('⇼');
|
|
|
|
direction.info({mills: now, direction: 'DoubleUp'}).label.should.equal('⇈');
|
|
direction.info({mills: now, direction: 'DoubleUp'}).entity.should.equal('⇈');
|
|
|
|
direction.info({mills: now, direction: 'SingleUp'}).label.should.equal('↑');
|
|
direction.info({mills: now, direction: 'SingleUp'}).entity.should.equal('↑');
|
|
|
|
direction.info({mills: now, direction: 'FortyFiveUp'}).label.should.equal('↗');
|
|
direction.info({mills: now, direction: 'FortyFiveUp'}).entity.should.equal('↗');
|
|
|
|
direction.info({mills: now, direction: 'Flat'}).label.should.equal('→');
|
|
direction.info({mills: now, direction: 'Flat'}).entity.should.equal('→');
|
|
|
|
direction.info({mills: now, direction: 'FortyFiveDown'}).label.should.equal('↘');
|
|
direction.info({mills: now, direction: 'FortyFiveDown'}).entity.should.equal('↘');
|
|
|
|
direction.info({mills: now, direction: 'SingleDown'}).label.should.equal('↓');
|
|
direction.info({mills: now, direction: 'SingleDown'}).entity.should.equal('↓');
|
|
|
|
direction.info({mills: now, direction: 'DoubleDown'}).label.should.equal('⇊');
|
|
direction.info({mills: now, direction: 'DoubleDown'}).entity.should.equal('⇊');
|
|
|
|
direction.info({mills: now, direction: 'NOT COMPUTABLE'}).label.should.equal('-');
|
|
direction.info({mills: now, direction: 'NOT COMPUTABLE'}).entity.should.equal('-');
|
|
|
|
direction.info({mills: now, direction: 'RATE OUT OF RANGE'}).label.should.equal('⇕');
|
|
direction.info({mills: now, direction: 'RATE OUT OF RANGE'}).entity.should.equal('⇕');
|
|
});
|
|
|
|
|
|
});
|