Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 committed Jun 4, 2024
1 parent 575efbc commit 4f283e4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/126720_seatalk_displays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var chai = require('chai')
chai.Should()
chai.use(require('chai-things'))
chai.use(require('@signalk/signalk-schema').chaiModule)

describe('126720 Seatalk Displays', function () {
it('birghtness converts', function () {
var tree = require('./testMapper').toNested(
JSON.parse(
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":126720, "description": "Seatalk1: Display Brightness", "fields":{"Manufacturer Code":"Raymarine","Industry Code":"Marine Industry", "Proprietary ID": 3212, "Command": "Brightness", "Group": "Helm 1", "Brightness":50}}'
)
)
tree.should.have.nested.property('electrical.displays.raymarine.helm1.brightness.value', .5)
})

it('display color converts', function () {
var tree = require('./testMapper').toNested(
JSON.parse(
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":126720, "description": "Seatalk1: Display Color", "fields":{"Manufacturer Code":"Raymarine","Industry Code":"Marine Industry", "Proprietary ID": 3212, "Command": "Color", "Group": "Helm 1", "Color":"Red/Black"}}'
)
)
tree.should.have.nested.property('electrical.displays.raymarine.helm1.color.value', "red/black")
})

})
33 changes: 33 additions & 0 deletions test/130845_simrad_displays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var chai = require('chai')
chai.Should()
chai.use(require('chai-things'))
chai.use(require('@signalk/signalk-schema').chaiModule)

describe('130845 Simrad Displays', function () {
it('birghtness converts', function () {
var tree = require('./testMapper').toNested(
JSON.parse(
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":130845,"fields":{"Manufacturer Code":"Simrad","Industry Code":"Marine Industry","Display Group": "Group 1", "Key":"Backlight level","Value":50}}'
)
)
tree.should.have.nested.property('electrical.displays.navico.group1.brightness.value', .5)
})

it('night mode converts', function () {
var tree = require('./testMapper').toNested(
JSON.parse(
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":130845,"fields":{"Manufacturer Code":"Simrad","Industry Code":"Marine Industry","Display Group": "Group 1", "Key":"Night mode","Value":4}}'
)
)
tree.should.have.nested.property('electrical.displays.navico.group1.nightMode.state.value', 1)
})

it('night mode color converts', function () {
var tree = require('./testMapper').toNested(
JSON.parse(
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":130845,"fields":{"Manufacturer Code":"Simrad","Industry Code":"Marine Industry","Display Group": "Group 1", "Key":"Night mode color","Value":1}}'
)
)
tree.should.have.nested.property('electrical.displays.navico.group1.nightModeColor.value', 'green')
})
})

0 comments on commit 4f283e4

Please sign in to comment.