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 test for clasp versions #145

Merged
merged 3 commits into from
Apr 26, 2018
Merged
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
39 changes: 38 additions & 1 deletion tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, it } from 'mocha';
import { expect } from 'chai';
import * as fs from 'fs';
const { spawnSync } = require('child_process');
import { getScriptURL, getFileType } from './../src/utils.js';

describe('Test help for each function', () => {
it('should output help for run command', () => {
Expand Down Expand Up @@ -142,6 +143,42 @@ describe.skip('Test clasp deploy function', () => {
});
});

describe.skip('Test clasp version and versions function', () => {
let versionNumber = '';
it('should create new version correctly', () => {
const result = spawnSync(
'clasp', ['version'], { encoding: 'utf8' },
);
expect(result.stdout).to.contain('Created version ');
expect(result.status).to.equal(0);
versionNumber = result.stdout.substring(result.stdout.lastIndexOf(" "), result.stdout.length-2);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gets version number of version created

Copy link
Contributor

Choose a reason for hiding this comment

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

tslint should've checked for spaces aside the - operator.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, use ' not ".

it('should list versions correctly', () => {
const result = spawnSync(
'clasp', ['versions'], { encoding: 'utf8' },
);
expect(result.stdout).to.contain('~ ');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally changing the ~ character (i.e. ) wouldn't break this test.
I suppose it's not that big of a deal if we change it later.

expect(result.stdout).to.contain(' Versions ~');
expect(result.stdout).to.contain(versionNumber + ' - ');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And checks if that version is listed.

expect(result.status).to.equal(0);
});
});
});

describe.skip('Test getScriptURL function from utils', () => {
it('should return the scriptURL correctly', () => {
const url = getScriptURL('abcdefghijklmnopqrstuvwxyz');
expect(url).to.equal('https://script.google.com/d/abcdefghijklmnopqrstuvwxyz/edit');
});
});

describe.skip('Test getFileType function from utils', () => {
it('should return the lowercase file type correctly', () => {
expect(getFileType('SERVER_JS')).to.equal('js');
expect(getFileType('GS')).to.equal('gs');
expect(getFileType('JS')).to.equal('js');
});
});

// Fails when you logged in using --ownkey flag
describe.skip('Test clasp logout function', () => {
it('should logout correctly', () => {
Expand Down Expand Up @@ -179,7 +216,7 @@ describe.skip('Test clasp logout function', () => {
* [ ] clasp deploy [version] [description]
* [ ] clasp redeploy <deploymentId> <version> <description>
* [ ] clasp version [description]
* [ ] clasp versions
* [x] clasp versions
*
* # Configs
* - .js and .gs files
Expand Down