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

spec/configuration.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 50
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
wmc 7
eloc 29
c 0
b 0
f 0
nc 1
mnd 0
bc 7
fnc 7
dl 0
loc 50
rs 10
bpm 1
cpm 1
noi 5

1 Function

Rating   Name   Duplication   Size   Complexity  
A configuration.js ➔ ??? 0 31 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 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
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).to.be.undefined
0 ignored issues
show
introduced by
The result of the property access to expect(mqttConfig.will).to.be.undefined is not used.
Loading history...
30
			done()
31
		})
32
		it('has the username as string', (done) => {
33
			expect(mqttConfig.username).to.have.string('yourusername')
34
			done()
35
		})
36
		it('has the password as string', (done) => {
37
			expect(mqttConfig.password).to.have.string('yourpassword')
38
			done()
39
		})
40
		it('has the port as integer', (done) => {
41
			expect(mqttConfig.port).to.be.integer()
42
			done()
43
		})
44
		it('has the qos as integer', (done) => {
45
			expect(mqttConfig.qos).to.be.integer()
46
			done()
47
		})
48
	})
49
50
})
51