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 downloadContent helper #43

Merged
merged 5 commits into from May 18, 2016

Conversation

Projects
None yet
2 participants
@mirontoli
Member

mirontoli commented May 15, 2016

I created a helper function for downloading a file, a csv file or text. This works even with utf-8 and opening it directly in Excel - a very common need in SharePoint development. An example is an "Export to Excel" button in Search based applications. Some more info can be found on my blog post:

@mirontoli

This comment has been minimized.

Show comment
Hide comment
@mirontoli

mirontoli May 15, 2016

Member

There were some errors in sputils.list functions. I am not sure how to fix them to satifsy travis :)

Member

mirontoli commented May 15, 2016

There were some errors in sputils.list functions. I am not sure how to fix them to satifsy travis :)

@roobie

This comment has been minimized.

Show comment
Hide comment
@roobie

roobie May 16, 2016

Member

From what I can see, the CI build worked fine.

Would it be possible to test this in some way? I'm thinking we could at least stub the browser functionality, and check that the function does validation as expected. E.g. test that options.content actually is validated in the function to be defined.

Also, I think we should use a more generic default file name (instead of "tolle.txt" =)

Member

roobie commented May 16, 2016

From what I can see, the CI build worked fine.

Would it be possible to test this in some way? I'm thinking we could at least stub the browser functionality, and check that the function does validation as expected. E.g. test that options.content actually is validated in the function to be defined.

Also, I think we should use a more generic default file name (instead of "tolle.txt" =)

@mirontoli

This comment has been minimized.

Show comment
Hide comment
@mirontoli

mirontoli May 16, 2016

Member

Thanks for the feedback. "tolle.txt" will be "download.txt" instead. I'll try to set up a test.

Member

mirontoli commented May 16, 2016

Thanks for the feedback. "tolle.txt" will be "download.txt" instead. I'll try to set up a test.

@mirontoli

This comment has been minimized.

Show comment
Hide comment
@mirontoli

mirontoli May 16, 2016

Member

Now I have added a test that checks that an Error is thrown when content is not provided. Perhaps there is more that could be tested if we rewrite the function, but I don't know how, yet.

Member

mirontoli commented May 16, 2016

Now I have added a test that checks that an Error is thrown when content is not provided. Perhaps there is more that could be tested if we rewrite the function, but I don't know how, yet.

@roobie

This comment has been minimized.

Show comment
Hide comment
@roobie

roobie May 16, 2016

Member

This is quite the difficult function to unit test, since it is heavily dependent on browser functionality and user interaction (like checking the downloaded file). Maybe we cannot test more than this, automatically. I think, regarding testing, the test you supplied is sufficient.

I've one more comment, though. the else is on a new line like:

if (...) {
}
else {
}

To keep the style consistent, we should put the else on the same line as } as such:

if (...) {
} else {
}
Member

roobie commented May 16, 2016

This is quite the difficult function to unit test, since it is heavily dependent on browser functionality and user interaction (like checking the downloaded file). Maybe we cannot test more than this, automatically. I think, regarding testing, the test you supplied is sufficient.

I've one more comment, though. the else is on a new line like:

if (...) {
}
else {
}

To keep the style consistent, we should put the else on the same line as } as such:

if (...) {
} else {
}
@roobie

This comment has been minimized.

Show comment
Hide comment
@roobie

roobie May 16, 2016

Member

as a relevant aside, we should perhaps include the rule disallowNewlineBeforeBlockStatements in jscs, to catch these types of stylistic matters

Member

roobie commented May 16, 2016

as a relevant aside, we should perhaps include the rule disallowNewlineBeforeBlockStatements in jscs, to catch these types of stylistic matters

@roobie

This comment has been minimized.

Show comment
Hide comment
@roobie

roobie May 16, 2016

Member

the rule I was referring to is disallowKeywordsOnNewLine

Member

roobie commented May 16, 2016

the rule I was referring to is disallowKeywordsOnNewLine

@mirontoli

This comment has been minimized.

Show comment
Hide comment
@mirontoli

mirontoli May 16, 2016

Member

Wow, that's perfectionism. I like it. I moved the "else" up to the } and I also added the rule disallowKeywordsOnNewLine to the .jscs.json.

Member

mirontoli commented May 16, 2016

Wow, that's perfectionism. I like it. I moved the "else" up to the } and I also added the rule disallowKeywordsOnNewLine to the .jscs.json.

@mirontoli

This comment has been minimized.

Show comment
Hide comment
@mirontoli

mirontoli May 18, 2016

Member

@roobie can we merge it now?

Member

mirontoli commented May 18, 2016

@roobie can we merge it now?

@roobie roobie merged commit d125f73 into master May 18, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment