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
Conversation
Signed-off-by: campionfellin <campionfellin@gmail.com>
Pull Request Test Coverage Report for Build 119
💛 - Coveralls |
Signed-off-by: campionfellin <campionfellin@gmail.com>
tests/test.ts
Outdated
|
||
describe.skip('Test getFileType function from utils', () => { | ||
it('should return the lowercase file type correctly', () => { | ||
const type = getFileType('SERVER_JS'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function only appears in index.ts
once. We could probably inline it, as all it does is a toLowerCase
unless the filetype is SERVER_JS
, where it then just converts it to js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is fine standalone. It's good to test it for coverage.
tests/test.ts
Outdated
'clasp', ['versions'], { encoding: 'utf8' }, | ||
); | ||
expect(result.stdout).to.contain('~ '); | ||
expect(result.stdout).to.contain(' Versions ~'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like a very strong test. Can we create a version, then ensure the version we created is the same as the version listed?
tests/test.ts
Outdated
const url = getScriptURL('abcdefghijklmnopqrstuvwxyz'); | ||
expect(url).to.equal('https://script.google.com/d/abcdefghijklmnopqrstuvwxyz/edit'); | ||
const url2 = getScriptURL('1234567890abcdefg'); | ||
expect(url2).to.equal('https://script.google.com/d/1234567890abcdefg/edit'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This URL doesn't test anything different than the previous URL.
Omit it.
tests/test.ts
Outdated
it('should return the lowercase file type correctly', () => { | ||
const type = getFileType('SERVER_JS'); | ||
expect(type).to.equal('js'); | ||
const type2 = getFileType('GS'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline all const
s in this function. They're only used once.
tests/test.ts
Outdated
|
||
describe.skip('Test getFileType function from utils', () => { | ||
it('should return the lowercase file type correctly', () => { | ||
const type = getFileType('SERVER_JS'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is fine standalone. It's good to test it for coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as requesting changes.
Signed-off-by: campionfellin <campionfellin@gmail.com>
); | ||
expect(result.stdout).to.contain('Created version '); | ||
expect(result.status).to.equal(0); | ||
versionNumber = result.stdout.substring(result.stdout.lastIndexOf(" "), result.stdout.length-2); |
There was a problem hiding this comment.
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
); | ||
expect(result.stdout).to.contain('~ '); | ||
expect(result.stdout).to.contain(' Versions ~'); | ||
expect(result.stdout).to.contain(versionNumber + ' - '); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The tslint comment can be addressed in a different PR.
); | ||
expect(result.stdout).to.contain('Created version '); | ||
expect(result.status).to.equal(0); | ||
versionNumber = result.stdout.substring(result.stdout.lastIndexOf(" "), result.stdout.length-2); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, use '
not "
.
const result = spawnSync( | ||
'clasp', ['versions'], { encoding: 'utf8' }, | ||
); | ||
expect(result.stdout).to.contain('~ '); |
There was a problem hiding this comment.
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.
Signed-off-by: campionfellin campionfellin@gmail.com
npm run test
succeeds.npm run lint
succeeds.