2018-01-05 17:43:52 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
let driverFactory, config;
|
|
|
|
let { DriverFactory } = require( '../drivers/driverfactory' );
|
|
|
|
|
|
|
|
let { Dummy } = require( '../drivers/dummy' );
|
|
|
|
let { PimoroniUnicorn } = require( '../drivers/pimoroniunicorn' );
|
2018-07-03 19:39:50 +02:00
|
|
|
let { MotionJPEG } = require( '../drivers/motionjpeg' );
|
2018-01-05 17:43:52 +01:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
driverFactory = new DriverFactory();
|
|
|
|
config = {
|
|
|
|
"driver": "dummy",
|
|
|
|
"matrix": {
|
|
|
|
"width": 16,
|
|
|
|
"height": 16,
|
|
|
|
"brightness": 1,
|
|
|
|
"flipHorizontal": false,
|
|
|
|
"flipVertical": false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Dummy driver to be properly created', () => {
|
2018-01-05 21:36:06 +01:00
|
|
|
let driver = driverFactory.createFromConfig( config );
|
|
|
|
|
|
|
|
driver.silence = true;
|
|
|
|
|
|
|
|
expect( driver ).toBeInstanceOf( Dummy );
|
|
|
|
expect( driver.write( driver.getBuffer() ) ).toBeUndefined();
|
2018-01-05 17:43:52 +01:00
|
|
|
} );
|
|
|
|
|
|
|
|
test( 'Pimoroni Unicorn driver to be properly created', () => {
|
|
|
|
config.driver = "pimoroniunicorn";
|
2018-01-05 21:36:06 +01:00
|
|
|
|
|
|
|
let driver = driverFactory.createFromConfig( config );
|
|
|
|
|
|
|
|
expect( driver ).toBeInstanceOf( PimoroniUnicorn );
|
|
|
|
expect( driver.write( driver.getBuffer() ) ).toBeUndefined();
|
2018-07-03 19:39:50 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
test( 'MotionJPEG driver to be properly created', () => {
|
|
|
|
config.driver = "motionjpeg";
|
|
|
|
|
|
|
|
let driver = driverFactory.createFromConfig( config );
|
|
|
|
|
|
|
|
expect( driver ).toBeInstanceOf( MotionJPEG );
|
|
|
|
expect( driver.write( driver.getBuffer() ) ).toBeUndefined();
|
2018-07-03 20:34:21 +02:00
|
|
|
|
|
|
|
driver.cleanup();
|
2018-01-05 17:43:52 +01:00
|
|
|
} );
|