Added very basic tests
This commit is contained in:
@ -5,7 +5,6 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/parnic/node-screenlogic.git",
|
"repository": "https://github.com/parnic/node-screenlogic.git",
|
||||||
"main": "index.js",
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"pentair",
|
"pentair",
|
||||||
"pool",
|
"pool",
|
||||||
@ -14,5 +13,11 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"smart-buffer": "~4.0.1"
|
"smart-buffer": "~4.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^5.1.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha test/*.spec.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
test/find.spec.js
Normal file
15
test/find.spec.js
Normal 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
62
test/unit.spec.js
Normal 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)
|
||||||
|
})
|
||||||
|
})
|
Reference in New Issue
Block a user