Passed
Pull Request — master (#2)
by André
01:18
created

spec/configuration.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 51
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
wmc 7
eloc 30
c 0
b 0
f 0
nc 1
mnd 0
bc 7
fnc 7
dl 0
loc 51
rs 10
bpm 1
cpm 1
noi 6

1 Function

Rating   Name   Duplication   Size   Complexity  
A configuration.js ➔ ??? 0 32 1
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 fixtureInput = require('./fixtures/input.json')
10
11
/**
12
 * Test behavior
13
 *
14
 * 1. Test configuration
15
 * - source: url, password
16
 * - params: payload, topic
17
 * 2. Test to send payloads
18
 * 3. Test callback to send status
19
 */
20
describe('configuration', () => {
21
22
	describe('MQTT', () => {
23
		let mqttConfig = configuration.mqtt(JSON.parse(JSON.stringify(fixtureInput)))
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
			expect(mqttConfig.will.topic).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.will.topic).to.not.be.undefined is not used.
Loading history...
30
			expect(mqttConfig.will.payload).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.will.p...ad).to.not.be.undefined is not used.
Loading history...
31
			done()
32
		})
33
		it('has the username as string', (done) => {
34
			expect(mqttConfig.username).to.have.string('yourusername')
35
			done()
36
		})
37
		it('has the password as string', (done) => {
38
			expect(mqttConfig.password).to.have.string('yourpassword')
39
			done()
40
		})
41
		it('has the port as integer', (done) => {
42
			expect(mqttConfig.port).to.be.integer()
43
			done()
44
		})
45
		it('has the qos as integer', (done) => {
46
			expect(mqttConfig.qos).to.be.integer()
47
			done()
48
		})
49
	})
50
51
})
52