mirror of
https://github.com/sexybiggetje/pixdisp.git
synced 2024-11-25 01:21:03 +01:00
Add some basic unit tests with Jest
This commit is contained in:
parent
c0923430c1
commit
7f106f4a3f
3 changed files with 3522 additions and 0 deletions
30
__tests__/driverfactory.js
Normal file
30
__tests__/driverfactory.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
let driverFactory, config;
|
||||
let { DriverFactory } = require( '../drivers/driverfactory' );
|
||||
|
||||
let { Dummy } = require( '../drivers/dummy' );
|
||||
let { PimoroniUnicorn } = require( '../drivers/pimoroniunicorn' );
|
||||
|
||||
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', () => {
|
||||
expect( driverFactory.createFromConfig( config ) ).toBeInstanceOf( Dummy );
|
||||
} );
|
||||
|
||||
test( 'Pimoroni Unicorn driver to be properly created', () => {
|
||||
config.driver = "pimoroniunicorn";
|
||||
expect( driverFactory.createFromConfig( config ) ).toBeInstanceOf( PimoroniUnicorn );
|
||||
} );
|
3482
package-lock.json
generated
3482
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
@ -9,5 +9,15 @@
|
|||
"dependencies": {
|
||||
"pi-spi": "^1.0.2",
|
||||
"restify": "^6.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^22.0.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"jest": {
|
||||
"name": "pixdisp",
|
||||
"testRegex": "(/__tests__/.[^_]*|(\\.|/)(test|spec))\\.jsx?$"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue