Skip to content

Commit

Permalink
Add basic help tests as examples (#112)
Browse files Browse the repository at this point in the history
* Make basic tests of help command output
* Remove sudo from build script
Signed-off-by: campionfellin <campionfellin@gmail.com>
  • Loading branch information
campionfellin authored and grant committed Apr 17, 2018
1 parent 38ef833 commit ef47d28
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"description": "Develop Apps Script Projects locally",
"main": "index.js",
"scripts": {
"build": "rm index.js; tsc --project tsconfig.json; sudo npm i -g;",
"build": "tsc --project tsconfig.json; npm i -g;",
"lint": "tslint -c tslint.json index.ts",
"test": "sh test.sh"
"test": "nyc --cache false mocha --timeout 100000",
"coverage": "nyc --cache false report --reporter=text-lcov | coveralls"
},
"bin": {
"clasp": "./index.js"
Expand Down Expand Up @@ -66,6 +67,10 @@
"@types/open": "^0.0.29",
"@types/pluralize": "^0.0.28",
"@types/recursive-readdir": "^2.2.0",
"chai": "^4.1.2",
"coveralls": "^3.0.0",
"mocha": "^5.1.0",
"nyc": "^11.6.0",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
}
Expand Down
27 changes: 27 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const expect = require('chai').expect;
const spawnSync = require('child_process').spawnSync;

describe('Test help for each function', () => {

it('should output help for run command', () => {
const result = spawnSync(
'clasp', ['run', '--help'], { encoding : 'utf8' }
);

expect(result.status).to.equal(0);
expect(result.stdout).to.include('Run a function in your Apps Scripts project');
});

it('should output help for logs command', () => {
const result = spawnSync(
'clasp', ['logs', '--help'], { encoding : 'utf8', detached: true }
);

expect(result.status).to.equal(0);
expect(result.stdout).to.include('Shows the StackDriver Logs');
});

});



0 comments on commit ef47d28

Please sign in to comment.