Advertisement
saasbook

movie_popup_spec.js

Aug 15th, 2013
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('MoviePopup', function() {
  2.   describe('setup', function() {
  3.     it('adds popup Div to main page', function() {
  4.       expect($('#movieInfo')).toExist();
  5.     });
  6.     it('hides the popup Div', function() {
  7.       expect($('#movieInfo')).toBeHidden();
  8.     });
  9.   });
  10.   describe('clicking on movie link', function() {
  11.     beforeEach(function() { loadFixtures('movie_row.html'); });
  12.     it('calls correct URL', function() {
  13.       spyOn($, 'ajax');
  14.       $('#movies a').trigger('click');
  15.       expect($.ajax.mostRecentCall.args[0]['url']).toEqual('/movies/1');
  16.     });
  17.     describe('when successful server call', function() {
  18.       beforeEach(function() {
  19.         var htmlResponse = readFixtures('movie_info.html');
  20.         spyOn($, 'ajax').andCallFake(function(ajaxArgs) {
  21.           ajaxArgs.success(htmlResponse, '200');
  22.         });
  23.         $('#movies a').trigger('click');
  24.       });
  25.       it('makes #movieInfo visible', function() {
  26.         expect($('#movieInfo')).toBeVisible();
  27.       });
  28.       it('places movie title in #movieInfo', function() {
  29.         expect($('#movieInfo').text()).toContain('Casablanca');
  30.       });
  31.     });
  32.   });
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement