initial unit tests
diff --git a/client/package.json b/client/package.json
index 4bf8747..ef01de3 100644
--- a/client/package.json
+++ b/client/package.json
@@ -1,10 +1,11 @@
{
- "name": "owdbg-client",
+ "name": "wskdb-client",
"version": "1.0.0",
- "description": "",
+ "description": "OpenWhisk debug client",
+ "repository": "https://github.ibm.com/nickm/owdbg",
"main": "client.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "ava --verbose"
},
"author": "",
"license": "ISC",
@@ -21,5 +22,8 @@
"tmp": "0.0.29",
"uuid": "^2.0.3",
"ws": "^1.1.1"
+ },
+ "devDependencies": {
+ "ava": "^0.16.0"
}
}
diff --git a/client/test/launchAndQuit.js b/client/test/launchAndQuit.js
new file mode 100644
index 0000000..d040281
--- /dev/null
+++ b/client/test/launchAndQuit.js
@@ -0,0 +1,19 @@
+import {test as it} from 'ava'
+var spawn = require('child_process').spawn
+
+it('should launch and quit without error', t => {
+ return new Promise((resolve,reject) => {
+ var child = spawn('node', ['wskdb.js'], { cwd: '..' })
+ child.stdin.write('q\n');
+
+ child.stderr.on('data', (data) => {
+ console.error('stderr: ' + data)
+ })
+ /*child.stdout.on('data', (data) => {
+ })*/
+ child.on('exit', (code) => {
+ if (code == 0) resolve()
+ else reject(code)
+ })
+ }).then(result => t.is(result))
+});
diff --git a/client/test/list.js b/client/test/list.js
new file mode 100644
index 0000000..588e3e4
--- /dev/null
+++ b/client/test/list.js
@@ -0,0 +1,29 @@
+import {test as it} from 'ava'
+const spawn = require('child_process').spawn
+
+it('should enumerate actions and quit without error', t => {
+ return new Promise((resolve,reject) => {
+ var child = spawn('node', ['wskdb.js'], { cwd: '..' })
+ child.stdin.write('l\n')
+
+ child.stderr.on('data', (data) => {
+ console.error('stderr: ' + data)
+ })
+
+ var goody = false;
+ child.stdout.on('data', (data) => {
+ // console.log('stdout: ' + data);
+ if (data.indexOf('Error') >= 0) {
+ goody = false
+
+ } else if (data.indexOf('ok') >= 0) {
+ child.stdin.write('q\n')
+ goody = true
+ }
+ });
+ child.on('exit', (code) => {
+ if (code == 0 && goody) resolve()
+ else reject('code=${code} goody=${goody}')
+ });
+ }).then(result => t.is(result))
+});