Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic help tests as examples #112

Merged
merged 2 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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', () => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time remove all these newlines.
(We should have a linter fail for these extra newlines everywhere).

it('should output help for run command', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 spaces everywhere.
(this should be checked by a lint rule next time)

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StackDriver logs

});

});