Passed
Push — master ( d06fb8...9f4cb8 )
by André
03:15 queued 01:29
created

spec/configuration.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 49
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 28
mnd 0
bc 0
fnc 7
dl 0
loc 49
rs 10
bpm 0
cpm 1
noi 4
c 0
b 0
f 0
1
'use strict'
2
3
const chai = require('chai')
4
const expect = chai.expect
5
chai.use(require('chai-integer'))
6
chai.use(require('chai-string'))
7
8
const configuration = require('../src/configuration.js')
9
const fixtureDefaults = require('./fixtures/configuration/defaults.json')
10
11
/**
12
 * Test behavior
13
 *
14
 * 1. Test sourceConfiguration
15
 * - source: url, password
16
 * - params: payload, topic
17
 * 2. Test to send payloads
18
 * 3. Test callback to send status
19
 */
20
describe('sourceConfiguration', () => {
21
	describe('MQTT with configuration', () => {
22
		let mqttConfig = configuration.mqtt(JSON.parse(JSON.stringify(fixtureDefaults)))
23
24
		it('has all properties defined', (done) => {
25
			expect(mqttConfig.username).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.username).to.not.be.undefined is not used.
Loading history...
26
			expect(mqttConfig.password).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.password).to.not.be.undefined is not used.
Loading history...
27
			expect(mqttConfig.port).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.port).to.not.be.undefined is not used.
Loading history...
28
			expect(mqttConfig.qos).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.qos).to.not.be.undefined is not used.
Loading history...
29
			done()
30
		})
31
		it('has the username as string', (done) => {
32
			expect(mqttConfig.username).to.have.string('test')
33
			done()
34
		})
35
		it('has the password as string', (done) => {
36
			expect(mqttConfig.password).to.have.string('test')
37
			done()
38
		})
39
		it('has the port as integer', (done) => {
40
			expect(mqttConfig.port).to.be.integer()
41
			done()
42
		})
43
		it('has the qos as integer', (done) => {
44
			expect(mqttConfig.qos).to.be.integer()
45
			done()
46
		})
47
	})
48
49
})
50