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

Merged
merged 5 commits into from May 18, 2016
Merged

add downloadContent helper #43

merged 5 commits into from May 18, 2016

Conversation

@mirontoli
Copy link
Member

@mirontoli 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
Copy link
Member Author

@mirontoli 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
Copy link
Contributor

@roobie 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
Copy link
Member Author

@mirontoli 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
Copy link
Member Author

@mirontoli 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
Copy link
Contributor

@roobie 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
Copy link
Contributor

@roobie 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
Copy link
Contributor

@roobie roobie commented May 16, 2016

the rule I was referring to is disallowKeywordsOnNewLine

@mirontoli
Copy link
Member Author

@mirontoli 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
Copy link
Member Author

@mirontoli mirontoli commented May 18, 2016

@roobie can we merge it now?

@roobie roobie merged commit d125f73 into master May 18, 2016
2 checks passed
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.