Jasmine js refactor