add downloadContent helper #43

Merged
merged 5 commits into from May 18, 2016

Projects

None yet

2 participants

@mirontoli
Member

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 mirontoli add downloadContent helper
9dd1c92
@mirontoli
Member

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

@mirontoli mirontoli FF support and namespace
3584468
@roobie
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
Member

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

@mirontoli mirontoli add tests, rename tolle.txt
dc7a67f
@mirontoli
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.

@roobie
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
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
Member
roobie commented May 16, 2016

the rule I was referring to is disallowKeywordsOnNewLine

mirontoli added some commits May 16, 2016
@mirontoli mirontoli else on the same line - stylistic improvement
ff4ba83
@mirontoli mirontoli add disallowKeywordsOnNewLine rule to jscs
7baa48d
@mirontoli
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.

@mirontoli
Member

@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