Last active
December 29, 2015 03:48
-
-
Save programmarchy/7609958 to your computer and use it in GitHub Desktop.
mocha in your serial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var SerialPort = require('serialport').SerialPort; | |
var device = require('./config.json')['device']; | |
describe('opening and closing a serial port', function() { | |
var serialport; | |
this.timeout(10000); | |
before(function() { | |
serialport = new SerialPort(device); | |
}); | |
it('should open', function(done) { | |
serialport.on('open', function() { | |
done(); | |
}); | |
}); | |
it('should close', function(done) { | |
serialport.on('close', function() { | |
done(); | |
}); | |
serialport.close(); | |
}); | |
it('should reopen', function(done) { | |
serialport.on('open', function() { | |
done(); | |
}); | |
serialport.open(); | |
}); | |
it('should close again', function(done) { | |
serialport.on('close', function() { | |
done(); | |
}); | |
serialport.close(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment