Skip to content

Commit 6311c12

Browse files
committed
Tessel.Port: ensure that bus protocol interface wrappers are constructors
Signed-off-by: Rick Waldron <[email protected]>
1 parent d3d37e5 commit 6311c12

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

node/test/unit/tessel.js

+26
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,32 @@ exports['Tessel.Port'] = {
766766

767767
test.done();
768768
},
769+
770+
busProtocolClassWrappersAreConstructors: function(test) {
771+
test.expect(6);
772+
773+
sandbox.stub(Tessel, 'I2C');
774+
sandbox.stub(Tessel, 'SPI');
775+
sandbox.stub(Tessel, 'UART');
776+
777+
var port = new Tessel.Port('B', '/foo/bar/baz', this.tessel);
778+
779+
test.doesNotThrow(() => {
780+
new port.I2C(1);
781+
});
782+
test.doesNotThrow(() => {
783+
new port.SPI({});
784+
});
785+
test.doesNotThrow(() => {
786+
new port.UART({});
787+
});
788+
789+
test.equal(Tessel.I2C.callCount, 1);
790+
test.equal(Tessel.SPI.callCount, 1);
791+
test.equal(Tessel.UART.callCount, 1);
792+
793+
test.done();
794+
},
769795
};
770796

771797
exports['Tessel.Port.prototype'] = {

0 commit comments

Comments
 (0)