Advertisement
Varun_Krishna

Writing jasmine unit test cases for button click event.

Jan 29th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- myfile.html-->
  2. Keyword: <input type = "text" /><br/>
  3. Country:<select>
  4. <option>--Select Country--</option>
  5. <option>....</option>
  6. </select>
  7. <button btn btn-primary ng-click = 'search()'>Search</button>
  8. <button btn btn-primary>clear</button>
  9. <!------- end of html ---->
  10. //search.spec.js
  11. describe("search spec or whatever", function(){
  12. //.... some code here
  13. var keyword, country,URL = "http://localhost/appname";
  14. //... some more codes here
  15. it('should retrieve the search results', function (){
  16. keyword = 'keyword';
  17. country = 'mycountry';
  18. // I also want to check whether the user has clicked the button search how do I do it? expect (button.submit).click();???
  19. // assume that the user enters keyword in the text box and selects mycountry from the dropdownlist box.
  20. //so when the user clicks search the url will be of this form and how do I need write unit test case here?
  21. var serv_res = $httpBackend.When('GET", URL + '?keyword =' + keyword + '&country = ' + country);
  22. // so here what my expectations should be?
  23. });
  24. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement