Friday, March 20, 2015

3/20/15 - Mocha, parseHTML

First of all, I messed up a commit to the repo.  I forgot to save my changes in WebIDE before committing, so this was added, which is definitely not what we want!  I committed the intended code, which makes a couple of changes (I love the branch compare feature, by the way!).  First of all, I pulled out the html stripping code into a dedicated method.  My two options seemed to be using either regular expressions or jQuery for the stripping.  I opted to use a regex, because jQuery has some weird behavior that I would not want hidden away and waiting to cause problems for code using #stripHTMLTags.  For example, passing a string like 'abcdef' does something unexpected: $('abcdef').text() returns "", I guess because 'abcdef' isn't valid html and so it just...ignores everything.  At first, I fixed this by ensuring the string was always enclosed in html tags: $('<html>' + string + '</html>').text() to ensure that in the case of no tags being present, the string is still returned.  I realized that this approach ugly and probably brings up other issues.  The regex, on the other hand, is very transparent in what it is doing, and easy to test as well (I'm using rubular for this because I can directly link to saved regex tests), so I chose to use it over jQuery.

Also, somehow we fixed the search function bug where it would only allow one search, even though we don't know what fixed it.  While it's good that it's fixed, it's worrying that seemingly unrelated functions are intertwined.

Also, I started looking at Mocha, but we ran out of time.  I had a little blast of nostalgia though, because I was looking over my tests from NSFPatents2, which I wrote over the summer.

1 comment:

  1. It is soooo cool that you did testing last Summer! Your college professors are going to love you, since they will be introducing so many things (like testing) to your peers for the first time, while you'll be able to say (hopefully not being too cocky about it ;-), "I've been doing that since high school."

    ReplyDelete