project_title_spec.js 1.8 KB
Newer Older
1
/* eslint-disable space-before-function-paren, no-unused-expressions, no-return-assign, no-param-reassign, no-var, new-cap, wrap-iife, no-unused-vars, quotes, jasmine/no-expect-in-setup-teardown, max-len */
2 3

/* global Project */
Fatih Acet's avatar
Fatih Acet committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

/*= require bootstrap */
/*= require select2 */
/*= require lib/utils/type_utility */
/*= require gl_dropdown */
/*= require api */
/*= require project_select */
/*= require project */

(function() {
  window.gon || (window.gon = {});

  window.gon.api_version = 'v3';

  describe('Project Title', function() {
19
    preloadFixtures('static/project_title.html.raw');
20 21
    loadJSONFixtures('projects.json');

Fatih Acet's avatar
Fatih Acet committed
22
    beforeEach(function() {
23
      loadFixtures('static/project_title.html.raw');
Fatih Acet's avatar
Fatih Acet committed
24 25 26
      return this.project = new Project();
    });
    return describe('project list', function() {
27 28 29
      var fakeAjaxResponse = function fakeAjaxResponse(req) {
        var d;
        expect(req.url).toBe('/api/v3/projects.json?simple=true');
Jacopo's avatar
Jacopo committed
30
        expect(req.data).toEqual({ search: '', order_by: 'last_activity_at', per_page: 20 });
31 32 33 34 35
        d = $.Deferred();
        d.resolve(this.projects_data);
        return d.promise();
      };

Fatih Acet's avatar
Fatih Acet committed
36 37
      beforeEach((function(_this) {
        return function() {
38
          _this.projects_data = getJSONFixture('projects.json');
39
          return spyOn(jQuery, 'ajax').and.callFake(fakeAjaxResponse.bind(_this));
Fatih Acet's avatar
Fatih Acet committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
        };
      })(this));
      it('to show on toggle click', (function(_this) {
        return function() {
          $('.js-projects-dropdown-toggle').click();
          return expect($('.header-content').hasClass('open')).toBe(true);
        };
      })(this));
      return it('hide dropdown', function() {
        $(".dropdown-menu-close-icon").click();
        return expect($('.header-content').hasClass('open')).toBe(false);
      });
    });
  });
}).call(this);