TDD in Brave Browser

Hao Chen
Haorc
Published in
2 min readApr 11, 2018

This week, I will try TDD to fix a small issue in the Brave Browser. To setup the browser, follow this guide.

Entering

https://www.google.ca/search?q=dog cat

into the browser will produce this :

No idea why someone would do this, but lets guard against it! The expected result should be simply ‘dog cat’ in google search. So I wrote a test in Mocha to test this expected behavior.

Breaks as expected at first.

This is my initial fix. I attempt to use Regex to find and replace the space within a given url with ‘%20’.

Although my test passed…something else broke. Now it fills in the space within a given domain name, something we do not want!

I added additional arguments to my Regex to ignore the occurrences of space within the domain name.

Voila~

--

--