Skip to content

Commit

Permalink
test: add testing led api getting the sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorbing committed Apr 21, 2018
1 parent 2d581e4 commit 6100c26
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tests/led/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export {
runLedTests,
} from './run-tests';
34 changes: 34 additions & 0 deletions src/tests/led/old-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { led } from '../..';
import { getDestroyPromise } from '../../error';


let isRunning = false;
function init()
{
const success = led.init();
console.log('success:', success);

if (!isRunning)
{
isRunning = true;
getDestroyPromise().then(() => shutdown());
}
}

export function shutdown()
{
if (isRunning)
{
console.log('shutting down old api');
led.shutdown();
isRunning = false;
}
}

export function testColor()
{
init();

const sdkVersion = led.getSdkVersion();
console.log('sdkVersion:', sdkVersion && sdkVersion.toString());
}
13 changes: 13 additions & 0 deletions src/tests/led/run-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { executeTest } from '../test-helper';
// import * as tests from './logi-led';
import * as oldTests from './old-api';


export async function runLedTests()
{
console.log('Old API');
console.log('---');

await executeTest('getting the sdk version', oldTests.testColor, 10e3);
oldTests.shutdown();
}
8 changes: 8 additions & 0 deletions src/tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { runGkeyTests } from './g-key';
import { runLcdTests } from './lcd';
import { runLedTests } from './led';


(async function ()
Expand All @@ -15,6 +16,13 @@ import { runLcdTests } from './lcd';
console.log('===');

await runGkeyTests();

console.log('');
console.log('');
console.log('Led');
console.log('===');

await runLedTests();
})()
.then(() =>
{
Expand Down

0 comments on commit 6100c26

Please sign in to comment.