uci-i2c-bus/test/device.test.js

25 lines
587 B
JavaScript

'use strict'
const chai = require('chai'),
chaiAsPromised = require('chai-as-promised'),
Bus = require('@uci/i2c').Bus,
Device = require('../lib/device').Device
chai.use(chaiAsPromised);
const expect = chai.expect
let bus = new Bus()
let device = new Device(bus, 0x20)
describe('Device Class - ', function () {
let SET = 0xff
it('Can write and read to actual device', function () {
device.write(0x09, SET).then(expect(device.read(0x0A)).to.eventually.equal(SET))
.then(setTimeout(() => device.write(0x09, 0), 3000))
.catch(err => console.log('an error', err))
})
})