uci-interrupt/test/interrupt.test.js

40 lines
1.1 KiB
JavaScript

'use strict'
// const expect = require('chai').expect
const Interrupt = require('../').Interrupt
//time-stamp for use when watching to distinguish reruns in console
// place in alpha first file only
let date = new Date(Date.now())
console.log(date.getMinutes(), "\:", date.getSeconds())
let inter17 = new Interrupt(17, {
hook: 'a hook to something to do'
// pullup: (num, state) => { return `someccommand using num and state` } // if rpi then specify a function that returns a command line line pullup tool using num and state
// pullup: 'external' // pullup not set with a command line utility - use alternative method such as device tree overlays
})
// inter17.on('fired', hook => {
// console.log('Listener fired and returned:', hook)
// })
inter17.init()
.then((resp) => {
console.log(resp)
console.log('initialzed, waiting for interrupt to fire')
})
.catch(err => console.log("returned error:\n", err))
inter17.on('fired', hook => { counter(hook) })
let count = 0
function counter(hook) {
count++
console.log(`******${count}********`)
console.log(hook)
console.log(`----------------------`)
}