Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Aug 26, 2018
1 parent 4411d85 commit 9e4e70c
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 10 deletions.
8 changes: 4 additions & 4 deletions characteristics/LockCurrentState.js
Expand Up @@ -6,19 +6,19 @@ module.exports = function (obj, iface) {

settings.topic.statusLock = settings.topic.statusLock || settings.topic.statusLockCurrentState;

/* istanbul ignore else */
/* istanbul ignore if */
if (typeof settings.payload.lockUnknown === 'undefined') {
settings.payload.lockUnknown = 3;
}
/* istanbul ignore else */
/* istanbul ignore if */
if (typeof settings.payload.lockJammed === 'undefined') {
settings.payload.lockJammed = 2;
}
/* istanbul ignore else */
/* istanbul ignore if */
if (typeof settings.payload.lockSecured === 'undefined') {
settings.payload.lockSecured = 1;
}
/* istanbul ignore else */
/* istanbul ignore if */
if (typeof settings.payload.lockUnsecured === 'undefined') {
settings.payload.lockUnsecured = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions characteristics/LockTargetState.js
Expand Up @@ -14,11 +14,11 @@ module.exports = function (obj, iface) {
if (typeof settings.payload.lockJammed === 'undefined') {
settings.payload.lockJammed = 2;
}
/* istanbul ignore else */
/* istanbul ignore if */
if (typeof settings.payload.lockSecured === 'undefined') {
settings.payload.lockSecured = 1;
}
/* istanbul ignore else */
/* istanbul ignore if */
if (typeof settings.payload.lockUnsecured === 'undefined') {
settings.payload.lockUnsecured = 0;
}
Expand Down
3 changes: 3 additions & 0 deletions services/Faucet.js
Expand Up @@ -13,14 +13,17 @@ module.exports = function (iface) {
*/

return function createService_Faucet(acc, settings, subtype) {
/* istanbul ignore else */
if (typeof settings.payload.activeTrue === 'undefined') {
settings.payload.activeTrue = true;
}

/* istanbul ignore else */
if (typeof settings.payload.activeFalse === 'undefined') {
settings.payload.activeFalse = false;
}

/* istanbul ignore if */
if (typeof settings.payload.faultTrue === 'undefined') {
settings.payload.faultTrue = true;
}
Expand Down
4 changes: 4 additions & 0 deletions services/IrrigationSystem.js
Expand Up @@ -4,18 +4,22 @@ module.exports = function (iface) {
const {mqttPub, mqttSub, mqttStatus, log, Service, Characteristic} = iface;

return function createService_IrrigationSystem(acc, settings, subtype) {
/* istanbul ignore else */
if (typeof settings.payload.activeTrue === 'undefined') {
settings.payload.activeTrue = true;
}

/* istanbul ignore if */
if (typeof settings.payload.inUseTrue === 'undefined') {
settings.payload.inUseTrue = true;
}

/* istanbul ignore else */
if (typeof settings.payload.faultTrue === 'undefined') {
settings.payload.faultTrue = true;
}

/* istanbul ignore else */
if (typeof settings.payload.activeFalse === 'undefined') {
settings.payload.activeFalse = false;
}
Expand Down
4 changes: 4 additions & 0 deletions services/Valve.js
Expand Up @@ -28,18 +28,22 @@ module.exports = function (iface) {
*/

return function createService_Valve(acc, settings, subtype) {
/* istanbul ignore if */
if (typeof settings.payload.activeTrue === 'undefined') {
settings.payload.activeTrue = true;
}

/* istanbul ignore if */
if (typeof settings.payload.inUseTrue === 'undefined') {
settings.payload.inUseTrue = true;
}

/* istanbul ignore if */
if (typeof settings.payload.faultTrue === 'undefined') {
settings.payload.faultTrue = true;
}

/* istanbul ignore if */
if (typeof settings.payload.activeFalse === 'undefined') {
settings.payload.activeFalse = false;
}
Expand Down
8 changes: 5 additions & 3 deletions test/test-am.json
Expand Up @@ -322,14 +322,16 @@
"name": "IrrigationSystem",
"service": "IrrigationSystem",
"topic": {
"setActive": "IrrigationSystem/set",
"statusActive": "IrrigationSystem/status",
"setActive": "IrrigationSystem/set/Active",
"statusActive": "IrrigationSystem/status/Active",
"statusProgramMode": "IrrigationSystem/status/ProgramMode",
"statusInUse": "IrrigationSystem/status/InUse",
"statusRemainingDuration": "IrrigationSystem/status/RemainingDuration",
"statusFault": "IrrigationSystem/status/Fault"
},
"payload": {},
"payload": {
"inUseTrue": 1
},
"config": {},
"props": {}
}
Expand Down
2 changes: 1 addition & 1 deletion test/test-cam.json
Expand Up @@ -53,6 +53,6 @@
"props": {}
}
],
"fileChangeIndicator": "xfw89l"
"fileChangeIndicator": "95ok5"
}
}
82 changes: 82 additions & 0 deletions test/test.js
Expand Up @@ -1640,6 +1640,67 @@ describe('HumiditySensor', () => {

testLowBattery('HumiditySensor');

describe('IrrigationSystem ProgramMode', () => {
it('homekit2mqtt should receive a status via mqtt and update it on hap', function (done) {
this.timeout(36000);
this.retries(5);
subscribe('homekit', /hap update IrrigationSystem ProgramMode 1/, () => {
done();
});
mqtt.publish('IrrigationSystem/status/ProgramMode', '1');
});
xit('client should get the ProgramMode', function (done) {
this.timeout(36000);
this.retries(5);
console.log('iid.IrrigationSystem', iid.IrrigationSystem);
cp.exec(clientCmd + ' get --aid ' + aid.IrrigationSystem + ' --iid ' + iid.IrrigationSystem.ProgramMode, (err, stdout, stderr) => {
if (stdout === '1\n') {
done();
}
});
});
});
describe('IrrigationSystem InUse', () => {
it('homekit2mqtt should receive a status via mqtt and update it on hap', function (done) {
this.timeout(36000);
this.retries(5);
subscribe('homekit', /hap update IrrigationSystem InUse 1/, () => {
done();
});
mqtt.publish('IrrigationSystem/status/InUse', '1');
});
xit('client should get the InUse', function (done) {
this.timeout(36000);
this.retries(5);
console.log('iid.IrrigationSystem', iid.IrrigationSystem);
cp.exec(clientCmd + ' get --aid ' + aid.IrrigationSystem + ' --iid ' + iid.IrrigationSystem.InUse, (err, stdout, stderr) => {
if (stdout === '1\n') {
done();
}
});
});
});
describe('IrrigationSystem RemainingDuration', () => {
it('homekit2mqtt should receive a status via mqtt and update it on hap', function (done) {
this.timeout(36000);
this.retries(5);
subscribe('homekit', /hap update IrrigationSystem RemainingDuration 100/, () => {
done();
});
mqtt.publish('IrrigationSystem/status/RemainingDuration', '100');
});
xit('client should get the RemainingDuration', function (done) {
this.timeout(36000);
this.retries(5);
console.log('iid.IrrigationSystem', iid.IrrigationSystem);
cp.exec(clientCmd + ' get --aid ' + aid.IrrigationSystem + ' --iid ' + iid.IrrigationSystem.RemainingDuration, (err, stdout, stderr) => {
if (stdout === '100\n') {
done();
}
});
});
});

describe('LeakSensor LeakSensorState', () => {
it('homekit2mqtt should receive a status via mqtt and update it on hap', function (done) {
this.timeout(36000);
Expand Down Expand Up @@ -3034,6 +3095,27 @@ describe('ThermostatSimple TemperatureDisplayUnits', () => {
});
});

describe('Valve InUse', () => {
it('homekit2mqtt should receive a status via mqtt and update it on hap', function (done) {
this.timeout(36000);
this.retries(5);
subscribe('homekit', /hap update Valve InUse 1/, () => {
done();
});
mqtt.publish('Valve/status/InUse', '1');
});
xit('client should get the status of InUse', function (done) {
this.timeout(36000);
this.retries(5);
console.log('iid.Valve', iid.Valve);
cp.exec(clientCmd + ' get --aid ' + aid.Valve + ' --iid ' + iid.Valve.InUse, (err, stdout, stderr) => {
if (stdout === '1\n') {
done();
}
});
});
});

describe('Window CurrentPosition', () => {
it('homekit2mqtt should receive a status via mqtt and update it on hap', function (done) {
this.timeout(36000);
Expand Down

0 comments on commit 9e4e70c

Please sign in to comment.