ChaptersListPageGenerator
codeChaptersListPageGenerator
testsFor some reason, there are two ways to test equality in our tests,
assert.equal()
and expect()
. I think the former is the mocha expression, and the latter is the chai expression. I tried to convert all our tests over to the expect()
syntax. I also found this page, which was helpful for writing the expect statements.In testing the chapters list page generator, I made my own stub for
HttpRequestHandler
, which is used to fetch the RSS chapter data that populates the chapters list. There's a stubbing/mocking library we might want to look into as well.I wasn't quite sure how to test the output of
#generatePage
since it's all within the page elements, and this is what I ended up with. I also found that I had to explicitly instantiate the <ul>
targeted by #pageGenerate
as a jQuery Mobile listview, otherwise this line in app.js would cause an error saying that the listview had not been initialized.I added a property to karma.conf.js to allow console.log statements to be outputted to the server console, which is helpful for debugging the tests
I don't think we need to test the private methods of ChapterListPageGenerator; they aren't part of any public interface, so there is no risk of cascading changes causing problems beyond
#generatePage.
if something is changed.I looked at how to make public and private methods in an object, and how inheritance works in JavaScript:
With a Foo() object set as Bar's prototype, all new Bar objects to send anything that they don't know how to handle up the message chain to Foo. So a method defined in Bar would override an identical method in Foo, but a method defined in Foo and not in Bar will work as though it is being called on Foo directly. This source was helpful in figuring stuff out.
No comments:
Post a Comment