# The Great Leap - getting serious with JavaScript at FINN.no

DevFeed: [The Great Leap - getting serious with JavaScript at FINN.no](<https://devfeed.tech/articles/the-great-leap-getting-serious-with-javascript-at-finn-no-31949.md>)

Original publisher: [Read original article](<https://tech.finn.no2011/04/01/the-great-leap-getting-serious-with-javascript-at-finn-no/>)

Author: espen

Published: 2011-04-01T11:45:39Z

Content type: article

Language: en

Sources: [Finn.no](<https://devfeed.tech/sources/finn-no.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [clean-code](<https://devfeed.tech/topics/clean-code.md>), [HTML](<https://devfeed.tech/topics/html.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [clean-code](<https://devfeed.tech/tags/clean-code.md>), [code](<https://devfeed.tech/tags/code.md>), [html](<https://devfeed.tech/tags/html.md>), [java](<https://devfeed.tech/tags/java.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [legacy](<https://devfeed.tech/tags/legacy.md>), [refactor](<https://devfeed.tech/tags/refactor.md>), [testing](<https://devfeed.tech/tags/testing.md>)

## AI overview

FINN.no describes a live coding session focused on testing JavaScript with Test-Driven Development. The examples include designing a type-ahead HTML widget and testing legacy JavaScript used in the platform's advanced search. The article also identifies a validation bug involving JavaScript's bitwise AND operator.

## Source excerpt

FINN.no are blessed to be based in the same country as one of the brightest young stars when it comes to testing in JavaScript and applying Test Driven Development: Christian Johansen (the poster above was used to promote the event). He works as a developer at Gitorious during the day time, but he also cranks out frameworks like SinonJS and he has even published a book on how to do Test Driven Development in JavaScript. Driving your design with tests We first had an amazing live coding session which he had previously done at FrontTrends. The task was to create a type-ahead widget which sent requests to a server if the delay was more than 50 millies. Driving the design of an HTML widget with tests is just as awesome as doing the same thing with JUint on the back-end. You get a nice set of really simple objects which provide you with a set of tools to create the functionality you want. This is very different from the one-object-with-everything kind of code you see a lot of when you do not focus upon design before you code. You can accomplish good clean code without Refactor some legacy code with tests We have just recently ported parts of our platform related to advanced search to a new Java framework, but we did not port much of the JavaScript code. Only thing we have done is to prevent it from flooding the global scope and extract the JS code into a separate file. Christian gave us the challenge of trying to test this code. This was by no means an easy task. The code was not written with testing in mind. It has some weird coding errors which for some reason does not produce errors in the user interface. Stuff like a function which one would expect to return a boolean, but when we tried to assertTrue on the result of a validation it failed and we couldn't see why. function validateForm() { var valid = true; $("input.number").each(function(){ valid &= validateInput($(this)); }); return valid; } ... if (validateForm()) { ....} That was until we noticed the bitwise and