mirror of
https://gitlab.silvrtree.co.uk/martind2000/SODashServer.git
synced 2025-01-11 18:45:08 +00:00
94 lines
2.8 KiB
JavaScript
94 lines
2.8 KiB
JavaScript
"use strict";
|
|
var should = require('should'), mqtt = require('mqtt'), mqttConnect = require('../lib/mqtt/mqttConnect');
|
|
|
|
describe('MQTT', function () {
|
|
beforeEach(function () {
|
|
mqttConnect.doConnection();
|
|
});
|
|
|
|
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 front light ON', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.lightingOn('1',function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
it('should turn the middle light ON', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.lightingOn('2',function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
it('should turn the back light ON', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.lightingOn('3',function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
it('should turn the front light OFF', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.lightingOff('a',function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
it('should turn the middle light OFF', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.lightingOff('b',function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
it('should turn the back light OFF', function (done) {
|
|
mqttConnect.client.on('connect', function () {
|
|
mqttConnect.lightingOff('c',function (err) {
|
|
should.not.exist(err);
|
|
});
|
|
done();
|
|
})
|
|
.on('error', function (err) {
|
|
done(err);
|
|
});
|
|
});
|
|
}); |