Files
cgm-remote-monitor/tests/upbat.test.js
T
Sulka HaroandGitHub 4ace12594e Move localisation to Crowdin (#6518)
* Update Crowdin configuration file

* Update Crowdin configuration file

* Add languages for pushing

* Update Crowdin configuration file

* Update source file en.json

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Romanian)

* New translations en.json (Dutch)

* New translations en.json (Croatian)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Chinese Traditional)

* New translations en.json (Chinese Simplified)

* New translations en.json (Turkish)

* New translations en.json (Swedish)

* New translations en.json (Slovenian)

* New translations en.json (Russian)

* New translations en.json (Polish)

* New translations en.json (Korean)

* New translations en.json (French)

* New translations en.json (Japanese)

* New translations en.json (Italian)

* New translations en.json (Hungarian)

* New translations en.json (Hebrew)

* New translations en.json (Greek)

* New translations en.json (German)

* New translations en.json (Danish)

* New translations en.json (Czech)

* New translations en.json (Bulgarian)

* New translations en.json (Spanish)

* New translations en.json (Norwegian Bokmal)

* New translations en.json (Chinese Traditional)

* New translations en.json (Chinese Simplified)

* Remove folders

* New translations en.json (Romanian)

* New translations en.json (Korean)

* New translations en.json (Croatian)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Chinese Traditional)

* New translations en.json (Turkish)

* New translations en.json (Swedish)

* New translations en.json (Slovenian)

* New translations en.json (Russian)

* New translations en.json (Polish)

* New translations en.json (Dutch)

* New translations en.json (Japanese)

* New translations en.json (French)

* New translations en.json (Italian)

* New translations en.json (Hungarian)

* New translations en.json (Hebrew)

* New translations en.json (Finnish)

* New translations en.json (Greek)

* New translations en.json (German)

* New translations en.json (Danish)

* New translations en.json (Czech)

* New translations en.json (Bulgarian)

* New translations en.json (Norwegian Bokmal)

* New translations en.json (Romanian)

* New translations en.json (Korean)

* New translations en.json (Croatian)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Turkish)

* New translations en.json (Swedish)

* New translations en.json (Slovenian)

* New translations en.json (Russian)

* New translations en.json (Polish)

* New translations en.json (Dutch)

* New translations en.json (Japanese)

* New translations en.json (French)

* New translations en.json (Italian)

* New translations en.json (Hungarian)

* New translations en.json (Hebrew)

* New translations en.json (Finnish)

* New translations en.json (Greek)

* New translations en.json (German)

* New translations en.json (Danish)

* New translations en.json (Czech)

* New translations en.json (Bulgarian)

* New translations en.json (Norwegian Bokmal)

* Update Crowdin configuration file

* New translations en.json (Spanish)

* New translations en.json (Chinese Simplified)

* New translations en.json (Chinese Traditional)

* New translations en.json (Italian)

* New translations en.json (Croatian)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Turkish)

* New translations en.json (Swedish)

* New translations en.json (Slovenian)

* New translations en.json (Russian)

* New translations en.json (Polish)

* New translations en.json (Dutch)

* New translations en.json (Korean)

* New translations en.json (Japanese)

* New translations en.json (Hungarian)

* New translations en.json (Hebrew)

* New translations en.json (Finnish)

* New translations en.json (Greek)

* New translations en.json (German)

* New translations en.json (Danish)

* New translations en.json (Czech)

* New translations en.json (Bulgarian)

* New translations en.json (French)

* New translations en.json (Romanian)

* New translations en.json (Norwegian Bokmal)

* Loading all languages now works

* * Fix unit tests
* Have server load localizations

* Adding some more keys

* New Crowdin updates (#6531)

* New translations en.json (Finnish)

* New translations en.json (Norwegian Bokmal)

* New translations en.json (Finnish)

* New translations en.json (Japanese)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Chinese Traditional)

* New translations en.json (Chinese Simplified)

* New translations en.json (Turkish)

* New translations en.json (Swedish)

* New translations en.json (Slovenian)

* New translations en.json (Russian)

* New translations en.json (Polish)

* New translations en.json (Dutch)

* New translations en.json (Korean)

* New translations en.json (Italian)

* New translations en.json (Norwegian Bokmal)

* New translations en.json (Hungarian)

* New translations en.json (Hebrew)

* New translations en.json (Greek)

* New translations en.json (German)

* New translations en.json (Danish)

* New translations en.json (Czech)

* New translations en.json (Bulgarian)

* New translations en.json (Spanish)

* New translations en.json (French)

* New translations en.json (Romanian)

* New translations en.json (Croatian)

* Update source file en.json

* New translations en.json (Norwegian Bokmal)

* New translations en.json (Norwegian Bokmal)

* Remove old translation status tool

* Update CONTRIBUTING
2020-11-17 14:17:17 +02:00

129 lines
3.7 KiB
JavaScript

'use strict';
require('should');
const fs = require('fs');
describe('Uploader Battery', function ( ) {
var data = {devicestatus: [{mills: Date.now(), uploader: {battery: 20}}]};
it('display uploader battery status', function (done) {
var sandbox = require('../lib/sandbox')();
var ctx = {
settings: {}
, language: require('../lib/language')(fs)
};
ctx.language.set('en');
ctx.levels = require('../lib/levels');
var sbx = sandbox.clientInit(ctx, Date.now(), data);
sbx.offerProperty = function mockedOfferProperty (name, setter) {
name.should.equal('upbat');
var result = setter();
result.display.should.equal('20%');
result.status.should.equal('urgent');
result.min.value.should.equal(20);
result.min.level.should.equal(25);
done();
};
var upbat = require('../lib/plugins/upbat')(ctx);
upbat.setProperties(sbx);
});
it('set a pill to the uploader battery status', function (done) {
var ctx = {
settings: {}
, pluginBase: {
updatePillText: function mockedUpdatePillText(plugin, options) {
options.value.should.equal('20%');
options.labelClass.should.equal('icon-battery-25');
options.pillClass.should.equal('urgent');
done();
}
}
, language: require('../lib/language')(fs)
};
ctx.language.set('en');
var sandbox = require('../lib/sandbox')();
var sbx = sandbox.clientInit(ctx, Date.now(), data);
var upbat = require('../lib/plugins/upbat')(ctx);
upbat.setProperties(sbx);
upbat.updateVisualisation(sbx);
});
it('hide the pill if there is no uploader battery status', function (done) {
var ctx = {
settings: {}
, pluginBase: {
updatePillText: function mockedUpdatePillText (plugin, options) {
options.hide.should.equal(true);
done();
}
}
, language: require('../lib/language')(fs)
};
ctx.language.set('en');
var sandbox = require('../lib/sandbox')();
var sbx = sandbox.clientInit(ctx, Date.now(), {});
var upbat = require('../lib/plugins/upbat')(ctx);
upbat.setProperties(sbx);
upbat.updateVisualisation(sbx);
});
it('hide the pill if there is uploader battery status is -1', function (done) {
var ctx = {
settings: {}
, pluginBase: {
updatePillText: function mockedUpdatePillText(plugin, options) {
options.hide.should.equal(true);
done();
}
}, language: require('../lib/language')(fs)
};
ctx.language.set('en');
var sandbox = require('../lib/sandbox')();
var sbx = sandbox.clientInit(ctx, Date.now(), {devicestatus: [{uploader: {battery: -1}}]});
var upbat = require('../lib/plugins/upbat')(ctx);
upbat.setProperties(sbx);
upbat.updateVisualisation(sbx);
});
it('should handle virtAsst requests', function (done) {
var ctx = {
settings: {}
, language: require('../lib/language')(fs)
};
ctx.language.set('en');
var sandbox = require('../lib/sandbox')();
var sbx = sandbox.clientInit(ctx, Date.now(), data);
var upbat = require('../lib/plugins/upbat')(ctx);
upbat.setProperties(sbx);
upbat.virtAsst.intentHandlers.length.should.equal(2);
upbat.virtAsst.intentHandlers[0].intentHandler(function next(title, response) {
title.should.equal('Uploader Battery');
response.should.equal('Your uploader battery is at 20%');
upbat.virtAsst.intentHandlers[1].intentHandler(function next(title, response) {
title.should.equal('Uploader Battery');
response.should.equal('Your uploader battery is at 20%');
done();
}, [], sbx);
}, [], sbx);
});
});