mirror of
https://gitlab.silvrtree.co.uk/martind2000/SODashServer.git
synced 2025-01-11 09:05:07 +00:00
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
"use strict";
|
|
var should = require('should'), mqtt = require('mqtt'), mqttConnect = require('../lib/mqtt/mqttConnect');
|
|
var mqttC;
|
|
describe('MQTT - Heating', function () {
|
|
before(function () {
|
|
// mqttC = mqttConnect.doConnection();
|
|
|
|
mqttC = new mqttConnect();
|
|
mqttC.connected();
|
|
});
|
|
|
|
it('should create client', function (done) {
|
|
mqttConnect.client.should.be.instanceOf(mqtt.MqttClient);
|
|
done();
|
|
});
|
|
|
|
it('should connect to IBM', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should turn the heating ON', function (done) {
|
|
/*mqttConnect.client.on('connect', function () {
|
|
mqttConnect.heatingOn(function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});*/
|
|
mqttC.heatingOn(function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
});
|
|
|
|
it('should turn the heating OFF', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.heatingOff(function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
|
|
}); |