This commit is contained in:
Koenkk
2018-11-19 20:29:35 +01:00
committed by Koen Kanters
parent c213a96133
commit dcb75b19d3
2 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ class DevicePublish {
topic = topic.replace(`/${type}`, '');
// Check if we have to deal with a postfix.
let postfix = null;
let postfix = '';
if (postfixes.find((p) => topic.endsWith(p))) {
postfix = topic.substr(topic.lastIndexOf('/') + 1, topic.length);
+7 -7
View File
@@ -50,7 +50,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'set');
chai.assert.strictEqual(parsed.deviceID, 'my_device_id');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
});
it('Should parse get topic', () => {
@@ -58,7 +58,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'get');
chai.assert.strictEqual(parsed.deviceID, 'my_device_id2');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
});
it('Should parse topic with when base topic has multiple slashes', () => {
@@ -74,7 +74,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'get');
chai.assert.strictEqual(parsed.deviceID, 'my_device_id2');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
stub.restore();
});
@@ -83,7 +83,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'set');
chai.assert.strictEqual(parsed.deviceID, 'floor0/basement/my_device_id2');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
});
it('Should parse topic with when base and deviceID have multiple slashes', () => {
@@ -99,7 +99,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'set');
chai.assert.strictEqual(parsed.deviceID, 'floor0/basement/my_device_id2');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
stub.restore();
});
@@ -108,7 +108,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'set');
chai.assert.strictEqual(parsed.deviceID, '0x12345689');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
});
it('Should parse set with postfix topic', () => {
@@ -140,7 +140,7 @@ describe('DevicePublish', () => {
const parsed = devicePublish.parseTopic(topic);
chai.assert.strictEqual(parsed.type, 'set');
chai.assert.strictEqual(parsed.deviceID, '0x12345689/invalid');
chai.assert.strictEqual(parsed.postfix, null);
chai.assert.strictEqual(parsed.postfix, '');
});
it('Should parse set with and slashes in base and deviceID postfix topic', () => {