Added very basic tests

This commit is contained in:
2018-04-28 22:41:38 -05:00
parent aac316c5ed
commit 26083f75a7
3 changed files with 83 additions and 1 deletions

View File

@ -5,7 +5,6 @@
"main": "index.js",
"license": "MIT",
"repository": "https://github.com/parnic/node-screenlogic.git",
"main": "index.js",
"keywords": [
"pentair",
"pool",
@ -14,5 +13,11 @@
],
"dependencies": {
"smart-buffer": "~4.0.1"
},
"devDependencies": {
"mocha": "^5.1.1"
},
"scripts": {
"test": "mocha test/*.spec.js"
}
}

15
test/find.spec.js Normal file
View File

@ -0,0 +1,15 @@
'use strict'
const ScreenLogic = require('../index');
// you'll need a ScreenLogic-enabled device on your network for this to succeed
describe('Finder', () => {
it('finds a server', done => {
let finder = new ScreenLogic.FindUnits();
finder.on('serverFound', server => {
finder.close()
done()
})
finder.search();
})
})

62
test/unit.spec.js Normal file
View File

@ -0,0 +1,62 @@
'use strict'
const ScreenLogic = require('../index');
// you'll need a ScreenLogic-enabled device on your network for this to succeed
describe('Unit', () => {
let unit
before(done => {
let finder = new ScreenLogic.FindUnits();
finder.on('serverFound', server => {
finder.close()
unit = new ScreenLogic.UnitConnection(server)
unit.on('loggedIn', () => {
done()
})
unit.connect()
})
finder.search();
})
after(() => {
unit.close()
})
let circuit
it('gets pool status', done => {
unit.on('poolStatus', status => {
circuit = status.circuitArray[0]
done()
})
unit.getPoolStatus()
})
it('gets controller config', done => {
unit.on('controllerConfig', config => { done() })
unit.getControllerConfig()
})
it('gets chemical data', done => {
unit.on('chemicalData', () => { done() })
unit.getChemicalData()
})
it('gets salt cell config', done => {
unit.on('saltCellConfig', () => { done() })
unit.getSaltCellConfig()
})
it('gets version', done => {
unit.on('version', () => { done() })
unit.getVersion()
})
it('sets circuit state', done => {
unit.on('circuitStateChanged', () => { done() })
unit.setCircuitState(0, circuit.id, circuit.state)
})
})